You are here

function fb_application_load in Drupal for Facebook 7.4

Drupal menu loader callback. Also a helper function to load locally stored information about a facebook application.

May return sensitive data including access tokens and application secrets. So handle the results with extreme caution!

2 calls to fb_application_load()
fb_canvas_app in ./fb_canvas.module
fb_debug_token in ./fb.module

File

./fb.module, line 347

Code

function fb_application_load($app_id) {

  // For convenience, allow the app_id to be either a namespace or a graph id.
  foreach (array(
    'namespace',
    'fba',
  ) as $id_field) {
    $fb_app = db_select('fb_application', 'fba')
      ->fields('fba')
      ->condition($id_field, $app_id, '=')
      ->execute()
      ->fetchAssoc();
    if (!empty($fb_app)) {
      break;
    }
  }

  // @todo Until code is cleaned up to use either 'fba' or 'client_id' consistently, allow both.
  $fb_app['client_id'] = $fb_app['fba'];

  // @todo Fix descrepency between name and title.
  if (!isset($fb_app['name'])) {
    $fb_app['name'] = $fb_app['title'];
  }
  if (!empty($fb_app['sdata']) && empty($fb_app['data'])) {
    $fb_app['data'] = unserialize($fb_app['sdata']);
  }
  return $fb_app;
}