You are here

function fb_api in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb.module \fb_api()
  2. 7.4 fb.module \fb_api()

Simple wrapper around $fb->api() which caches data. Does not support the polymorphic arguments of $fb->api(). This is not a replacement for that function.

This is intended to avoid performace problems when, for example, $fb->api('me') is called several times in a single request.

Parameters

$graph_path: Something facebook's graph API will understand. Could be an ID or a path like 'me/accounts', for example.

$params: Extras to pass to the graph API. When making a request that requires a token, try array('access_token' => fb_get_token()).

3 calls to fb_api()
fb_permission_access_perms in contrib/fb_permission.module
fb_user_form_user_profile_form_alter in ./fb_user.module
Implements hook_form_user_profile_form_alter.
_fb_user_facebook_data in ./fb_user.module

File

./fb.module, line 1725
This is the core required module of Drupal for Facebook.

Code

function fb_api($graph_path, $params = array()) {
  static $cache;
  $fb = $GLOBALS['_fb'];
  if (!$fb) {
    return;
  }
  if (!isset($cache)) {
    $cache = array();
  }
  if (!isset($cache[$graph_path])) {
    $cache[$graph_path] = $fb
      ->api($graph_path, $params);
  }
  return $cache[$graph_path];
}