You are here

function fb_users_getInfo in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 5.2 fb.module \fb_users_getInfo()
  2. 5 fb.module \fb_users_getInfo()
  3. 6.3 fb.module \fb_users_getInfo()
  4. 7.3 fb.module \fb_users_getInfo()

Helper function for facebook's users_getInfo API.

This function makes calls to users_getInfo more efficient, by caching results in the session, so calls do not always require hitting Facebook's servers.

Parameters

$oids: Array of facebook object IDs. In this case they should each be a user id.

7 calls to fb_users_getInfo()
fb_devel_user in ./fb_devel.module
fb_form_friend_selector_value in ./fb_form.module
Convert #default_value into a value for the form field
fb_register_fb in contrib/fb_register.module
Implementation of hook_fb(). Here we customize the behavior of Drupal for Facebook.
fb_username_alter in ./fb.module
hook_username_alter().
fb_user_create_local_user in ./fb_user.module
Creates a local Drupal account for the specified facebook user id.

... See full list

File

./fb.module, line 855

Code

function fb_users_getInfo($oids, $fb = NULL, $refresh_cache = FALSE) {
  if (!$fb) {
    $fb = $GLOBALS['_fb'];
  }
  $infos = array();
  if (!is_array($oids)) {
    $oids = array();
  }
  if ($fb) {

    // First try cache
    if (!$refresh_cache) {
      foreach ($oids as $oid) {
        if ($info = $_SESSION['fb'][$fb->api_key]['userinfo'][$oid]) {
          $infos[] = $info;
        }
      }
    }
    if (count($infos) != count($oids)) {

      // Session cache did not include all users, update the cache.
      $infos = $fb->api_client
        ->users_getInfo($oids, array(
        'about_me',
        'affiliations',
        'name',
        'is_app_user',
        'pic',
        'pic_big',
        'pic_square',
        'profile_update_time',
        'proxied_email',
        'status',
        'email_hashes',
        'email',
      ));

      // Update cache with recent results.
      if (is_array($infos)) {
        foreach ($infos as $info) {
          $_SESSION['fb'][$fb->api_key]['userinfo'][$info['uid']] = $info;
        }
      }
    }
    return $infos;
  }
}