You are here

function fbconnect_get_fbuid in Facebook Connect 7.2

Same name and namespace in other branches
  1. 8.2 fbconnect.module \fbconnect_get_fbuid()
  2. 5 fbconnect.module \fbconnect_get_fbuid()
  3. 6.2 fbconnect.module \fbconnect_get_fbuid()
  4. 6 fbconnect.module \fbconnect_get_fbuid()

Check Facebook session.

Parameters

boolean $check_connected: ensure that active user is connected with active Facebook account

Return value

integer Facebook user id

12 calls to fbconnect_get_fbuid()
fbconnect_fbapp_settings in ./fbconnect.admin.inc
fbconnect_fbapp_settings_submit in ./fbconnect.admin.inc
fbconnect_get_user_info in ./fbconnect.module
Query information from Facebook user table.
fbconnect_invite_block_view in fbconnect_invite/fbconnect_invite.module
Implements hook_block_view().
fbconnect_login_autoconnect_form_submit in fbconnect_login/fbconnect_login.module
Submit handler for autoconnect form.

... See full list

File

./fbconnect.module, line 271
Facebook Connect API module.

Code

function fbconnect_get_fbuid($check_connected = FALSE) {
  global $user;
  $fb_session = facebook_client_session();
  if (empty($fb_session)) {
    return NULL;
  }
  if ($request = (new FacebookRequest($fb_session, 'GET', '/me'))
    ->execute()) {
    try {
      $me = (new FacebookRequest($fb_session, 'GET', '/me'))
        ->execute()
        ->getGraphObject(Facebook\GraphUser::className());
      $fbuid = $me
        ->getId();
      if (module_exists('fbconnect_login') && $check_connected && $fbuid) {
        if (_get_user_fbuid($user->uid) != $fbuid) {
          $fbuid = NULL;
        }
      }
    } catch (Exception $e) {
      $fbuid = NULL;
    }
  }
  return $fbuid;
}