You are here

function fb_load in Drupal for Facebook 7.4

Same name and namespace in other branches
  1. 6.3 fb.module \fb_load()
  2. 6.2 fb.module \fb_load()
  3. 7.3 fb.module \fb_load()

Implementation of a %wildcard_load(). http://drupal.org/node/224170

Handles menu items with %fb in the path by querying facebook graph for data.

Parameters

$id: Path on the facebook graph. Usually the ID of a graph object.

$params: Optional array of parameter to pass to fb_graph(). Can be used to specify an access_token.

File

./fb.module, line 317

Code

function fb_load($id, $params = array()) {
  if (!$id) {
    return array();
  }
  $cache =& drupal_static(__FUNCTION__);
  $token =& drupal_static('fb_load_token');
  if (!isset($cache)) {
    $cache = array();
  }
  if (!isset($cache[$id])) {
    try {
      drupal_alter('fb_load', $token, $params, $id);

      // Allow third parties to change settings.
      // Query facebook for data.
      $cache[$id] = fb_graph($id, $params + array(
        'access_token' => $token,
      ));
    } catch (exception $e) {
      fb_log_exception($e, t('Failed to query facebook for url argument %id', array(
        '%id' => $id,
      )));
      $cache[$id] = array(
        'id' => $id,
      );
    }
  }
  return $cache[$id];
}