You are here

function fb_get_app in Drupal for Facebook 7.4

Same name and namespace in other branches
  1. 5.2 fb.module \fb_get_app()
  2. 5 fb.module \fb_get_app()
  3. 6.3 fb.module \fb_get_app()
  4. 6.2 fb.module \fb_get_app()
  5. 7.3 fb.module \fb_get_app()

Gets details about a previously configured Facebook application.

Typically used to get the current app. In the simple case (i.e. a website with just one app devoted to Facebook Connect) returns the "default" app. In more complex cases (i.e. Drupal hosts multiple canvas page apps) this function allows other modules to select the app, via hook_fb_app_alter().

23 calls to fb_get_app()
fb_api in ./fb.module
Facebook's older api methods.
fb_auth_get_token in ./fb.module
When user returns from fb_auth process, $_REQUEST might contain token details.
fb_canvas_url_outbound_alter in ./fb_canvas.module
fb_client_auth_url in ./fb.module
Produce a client side auth URL as described in https://developers.facebook.com/docs/authentication/client-side/
fb_connect_admin_form in ./fb_connect.admin.inc
Form callback.

... See full list

File

./fb.module, line 715

Code

function fb_get_app($variable = NULL) {
  if ($variable) {
    $app = variable_get($variable, array());
  }
  else {
    $app = variable_get(FB_VAR_DEFAULT_APP, array());
  }

  // Allow other modules to change result.
  drupal_alter('fb_app', $app, $variable);
  if (empty($app)) {
    return FALSE;
  }

  // Defaults to avoid PHP errors.
  $app += array(
    'fba' => NULL,
    'client_id' => NULL,
    'namespace' => NULL,
    'name' => NULL,
  );

  // For historical reasons, we use 'fba' for the app id.  Facebook has
  // started using 'client_id'. @todo cleanup all code to use just one or
  // the other.
  if (!empty($app['client_id'])) {
    $app['fba'] = $app['client_id'];
  }
  if (empty($app['client_id'])) {
    $app['client_id'] = $app['fba'];
  }

  // Debug sanity check!
  if (!is_array($app)) {
    return array();
  }
  return $app;
}