function fb_init in Drupal for Facebook 7.4
Same name and namespace in other branches
- 5.2 fb.module \fb_init()
- 5 fb.module \fb_init()
- 6.3 fb.module \fb_init()
- 6.2 fb.module \fb_init()
- 7.3 fb.module \fb_init()
File
- ./
fb.module, line 59
Code
function fb_init() {
$fb_app = fb_get_app();
if ($fb_app) {
$fba = $fb_app['client_id'];
$access_token = fb_user_token($fb_app);
}
else {
$fba = 0;
$access_token = null;
}
// Javascript settings needed by fb.js.
drupal_add_js(array(
'fb' => array(
'client_id' => $fba,
// Default app.
'ajax_event_url' => url(FB_PATH_AJAX_EVENT, array(
'absolute' => TRUE,
)),
'fb_reloading' => !empty($_REQUEST['fb_reloading']),
'status' => $access_token ? 'connected' : 'unknown',
),
), 'setting');
drupal_add_library('system', 'jquery.cookie');
if ($fb_app) {
// App-specific details under app id, so that javascript can potentially work with more than one app at a time.
// Note that $fba must be prepended, as integers are unsafe to use as keys in drupal_add_js(). See drupal_array_merge_deep_array().
drupal_add_js(array(
'fb_app_' . $fba => _fb_js_settings($fb_app),
), 'setting');
}
if (variable_get(FB_VAR_ADD_JS, FALSE)) {
// Use Facebook's Javascript SDK.
fb_require_js();
}
// Let third parties know that fb.module is initialized.
fb_invoke(FB_OP_POST_INIT, array(
'fb_app' => $fb_app,
));
}