You are here

function fb_connect_app_init in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 5.2 fb_connect.module \fb_connect_app_init()
  2. 6.2 fb_connect.module \fb_connect_app_init()
  3. 7.3 fb_connect.module \fb_connect_app_init()

Prepare for fbConnect use. Because a single Drupal might support multiple apps, we don't know in advance which is the fbConnect app.

1 call to fb_connect_app_init()
fb_connect_block in ./fb_connect.module
Implements hook_block().

File

./fb_connect.module, line 45
Support for Facebook Connect features

Code

function fb_connect_app_init($fb_app) {
  if (isset($GLOBALS['_fb_app']) && $GLOBALS['_fb_app']->apikey != $fb_app->apikey) {

    // If we're in an iframe, only support connect for the iframe app.
    return;
  }
  if ($fb = fb_api_init($fb_app)) {
    $fbu = $fb
      ->getUser();
    if ($fbu && (!isset($GLOBALS['_fb_app']) || $GLOBALS['_fb_app']->apikey != $fb_app->apikey)) {

      // The user has authorized the app and we now know something about them.  Use a hook to trigger the actions of other modules.
      fb_invoke(FB_OP_APP_IS_AUTHORIZED, array(
        'fbu' => $fbu,
        'fb_app' => $fb_app,
        'fb' => $fb,
      ));
    }

    // Remember which app we've initialized.
    _fb_connect_set_app($fb_app);
    _fb_connect_add_js($fb_app, $fb);
  }
  return $fb;
}