You are here

function fb_app_get_app_properties in Drupal for Facebook 5.2

Get properties from Facebook. Fills in the data that we need to know by querying facebook.

4 calls to fb_app_get_app_properties()
fb_app_insert in ./fb_app.module
fb_app_update in ./fb_app.module
fb_app_validate in ./fb_app.module
fb_app_view in ./fb_app.module

File

./fb_app.module, line 288
Defines a custom node type that stores a facebook application configuration.

Code

function fb_app_get_app_properties(&$fb_app) {
  static $cache;
  static $props_map;
  if (!isset($cache)) {
    $cache = array();

    // http://wiki.developers.facebook.com/index.php/ApplicationProperties
    $props_map = array(
      t('About URL') => 'about_url',
      t('Application Name') => 'application_name',
      t('Edit URL') => 'edit_url',
    );
    $props_map = fb_invoke(FB_OP_LIST_PROPERTIES, array(
      'fb_app' => $fb_app,
    ), $props_map);
  }
  if (!isset($cache[$fb_app->apikey])) {
    if ($fb = fb_api_init($fb_app, FB_FBU_NO_SESSION)) {
      try {
        $props = $fb->api_client
          ->admin_getAppProperties(array_values($props_map));
      } catch (Exception $e) {
        fb_log_exception($e, t('Failed to get application properties from Facebook'));
      }
      $cache[$fb_app->apikey] = $props;
    }
  }
  else {
    $props = $cache[$fb_app->apikey];
  }

  // Update $fb_app with the values we got from facebook api.
  foreach ($props_map as $key) {
    if ($props[$key]) {
      $fb_app->{$key} = $props[$key];
    }
  }
}