You are here

function fb_connect_app_init in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb_connect.module \fb_connect_app_init()
  2. 6.3 fb_connect.module \fb_connect_app_init()
  3. 6.2 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_view in ./fb_connect.module

File

./fb_connect.module, line 44
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.
    watchdog('fb_connect', 'Unable to initialize facebook application %label1, because %label2 is already initialized.', array(
      '%label1' => $fb_app->label,
      '%label2' => $GLOBALS['_fb_app']->label,
    ), WATCHDOG_ERROR);
    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;
}