You are here

function fb_admin_get_app_properties in Drupal for Facebook 6.2

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

4 calls to fb_admin_get_app_properties()
fb_admin_app_page in ./fb.admin.inc
fb_admin_page in ./fb.admin.inc
Drupal page callback.
fb_app_admin_form_submit in ./fb_app.admin.inc
fb_app_edit_form_validate in ./fb_app.admin.inc
Form validation.

File

./fb.admin.inc, line 134
Admin pages and forms for Drupal for Facebook.

Code

function fb_admin_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_ADMIN_OP_LIST_PROPERTIES, array(
      'fb_app' => $fb_app,
    ), $props_map, FB_ADMIN_HOOK);
  }
  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));
        $cache[$fb_app->apikey] = $props;
      } catch (Exception $e) {
        fb_log_exception($e, t('Failed to get application properties (%label) from Facebook', array(
          '%label' => $fb_app->label,
        )));
      }
    }
    else {
      drupal_set_message(t("Failed to get application properties.  Could not initialize facebook API."), 'error');
    }
  }
  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];
    }
  }
}