function fbconnect_user_profile in Facebook Connect 8.2
Same name and namespace in other branches
- 7.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 146 - @todo.
Code
function fbconnect_user_profile() {
$user_profile = NULL;
if (($client = facebook_client()) && ($request = $client
->request('GET', '/me', array(), facebook_get_access_token()))) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$response = $client
->getClient()
->sendRequest($request);
$user_profile = $response
->getGraphUser()
->asArray();
} catch (Exception $e) {
$user_profile = NULL;
}
}
return $user_profile;
}