You are here

function fb_api in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 7.4 fb.module \fb_api()
  2. 7.3 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()).

2 calls to fb_api()
fb_user_user in ./fb_user.module
Implementation of hook_user().
_fb_user_facebook_data in ./fb_user.module

File

./fb.module, line 1458
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];
}