I want a content type having a field "FB URL" that get the URL of a Facebook Event and that when people load a node of this type, the content of the facebook event is retrieved through FB API. It cannot be retrieved from the database because the content must be up to date with the one on facebook.

So far, I created a module with node_load() to add content while the node is loaded but I don't know what function to call from FBOauth module to do so... Before that, I tried with a simple file_get_contents(); that worked well until the access token from the FB App expired and didn't know how to get a new one dynamically.

I think I'm getting lost so could anyone guide me on how to do that?

Thanks a lot!

1 Answer 1


Ok, I found!

function fb_event_crawler_node_load($nodes, $types) {
    foreach ($nodes as $node) {
        if ($node->type=="event"){
            $fb_url = $node->field_event_url['und'][0]['value'];
            $url = parse_url($fb_url);
            if (!$url['host'] == 'www.facebook.com'){
                echo t('This is not a Facebook URL');

            $path_exploded = explode("/", $url['path']);
            if (!$path_exploded[1] == 'events'){
                echo t("This is not a Facebook event page!");


                // dpm($path_exploded);

            $app_id = isset($app_id) ? $app_id : variable_get('fboauth_id', '');
            $app_secret = isset($app_secret) ? $app_secret : variable_get('fboauth_secret', '');
            $app_token_url = "https://graph.facebook.com/oauth/access_token?"
            . "client_id=" . $app_id
            . "&client_secret=" . $app_secret 
            . "&grant_type=client_credentials";

            $response = file_get_contents($app_token_url);
            $params = null;
            parse_str($response, $params);


            $fbquery = fboauth_graph_query($fb_event_id."/", $access_token);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.