public function FacebookAuthManager::getUserInfo in Social Auth Facebook 8
Same name and namespace in other branches
- 8.2 src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getUserInfo()
- 3.x src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getUserInfo()
Makes an API call to get user's Facebook profile.
Parameters
string $fields: The fields to retrieve.
Return value
\Facebook\GraphNodes\GraphNode|false GraphNode representing the user False if exception was thrown
File
- src/
FacebookAuthManager.php, line 160
Class
- FacebookAuthManager
- Contains all Simple FB Connect logic that is related to Facebook interaction.
Namespace
Drupal\social_auth_facebookCode
public function getUserInfo($fields = 'id,name,email') {
try {
return $this
->getClient()
->get('/me?fields=' . $fields)
->getGraphNode();
} catch (FacebookResponseException $ex) {
$this->loggerFactory
->get('simple_fb_connect')
->error('Could not load Facebook user profile: FacebookResponseException: @message', [
'@message' => json_encode($ex
->getMessage()),
]);
} catch (FacebookSDKException $ex) {
$this->loggerFactory
->get('simple_fb_connect')
->error('Could not load Facebook user profile: FacebookSDKException: @message', [
'@message' => $ex
->getMessage(),
]);
}
// Something went wrong.
return FALSE;
}