You are here

public function FacebookAuthManager::getEmail in Social Auth Facebook 8

Returns user's email address from Facebook profile.

Parameters

\Facebook\GraphNodes\GraphNode $fb_profile: GraphNode object representing user's Facebook profile.

Return value

string|false User's email address if found False otherwise

File

src/FacebookAuthManager.php, line 320

Class

FacebookAuthManager
Contains all Simple FB Connect logic that is related to Facebook interaction.

Namespace

Drupal\social_auth_facebook

Code

public function getEmail(GraphNode $fb_profile) {
  if ($email = $fb_profile
    ->getField('email')) {
    return $email;
  }

  // Email address was not found. Log error and return FALSE.
  $this->loggerFactory
    ->get('social_auth_facebook')
    ->error('No email address in Facebook user profile');
  return FALSE;
}