You are here

public function FacebookAuthManager::getProfile in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  2. 8.2 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  3. 8.3 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  4. 8.4 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  5. 8.5 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  6. 8.6 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  7. 8.7 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()
  8. 8.8 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getProfile()

Returns object of a user profile.

Return value

mixed Returns the profile.

Overrides AuthManagerInterface::getProfile

3 calls to FacebookAuthManager::getProfile()
FacebookAuthManager::getAccountId in modules/custom/social_auth_facebook/src/FacebookAuthManager.php
Returns an account ID on a social network.
FacebookAuthManager::getFirstName in modules/custom/social_auth_facebook/src/FacebookAuthManager.php
Returns first name on a social network if it possible.
FacebookAuthManager::getLastName in modules/custom/social_auth_facebook/src/FacebookAuthManager.php
Returns last name on a social network if it possible.

File

modules/custom/social_auth_facebook/src/FacebookAuthManager.php, line 88

Class

FacebookAuthManager
Class FacebookAuthManager.

Namespace

Drupal\social_auth_facebook

Code

public function getProfile() {
  try {
    $this->profile = $this->sdk
      ->get('/me?fields=id,name,email,first_name,last_name')
      ->getGraphNode();
  } catch (FacebookResponseException $e) {
    $this->loggerFactory
      ->get('social_auth_facebook')
      ->error('Could not load Facebook user profile: FacebookResponseException: @message', [
      '@message' => $e
        ->getMessage(),
    ]);
    return NULL;
  } catch (FacebookSDKException $e) {
    $this->loggerFactory
      ->get('social_auth_facebook')
      ->error('Could not load Facebook user profile: FacebookSDKException: @message', [
      '@message' => $e
        ->getMessage(),
    ]);
    return NULL;
  }
  return $this->profile;
}