You are here

function fbconnect_user_profile in Facebook Connect 7.2

Same name and namespace in other branches
  1. 8.2 fbconnect.module \fbconnect_user_profile()

Get the user profile or return null if they are not logged in and registered.

Return value

user_profile array

2 calls to fbconnect_user_profile()
fbconnect_login_init in fbconnect_login/fbconnect_login.module
Implements hook_init().
fbconnect_login_render_button in fbconnect_login/fbconnect_login.module
Render a custom button to log in via Facebook.

File

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

Code

function fbconnect_user_profile() {
  $user_profile = NULL;
  $fb_session = facebook_client_session();
  if (empty($fb_session)) {
    return NULL;
  }
  if ($request = (new FacebookRequest($fb_session, 'GET', '/me'))
    ->execute()) {
    try {

      // Proceed knowing you have a logged in user who's authenticated.
      $user_profile = $request
        ->getGraphObject()
        ->asArray();
    } catch (Exception $e) {
      $user_profile = NULL;
    }
  }
  return $user_profile;
}