title: Facebook SDK PHP Display a users email address
body: <p>So I am using the Facebook SDK for Facebook Login and have followed their docs as it shows although I can't seem to figure out how to echo the users email address?</p>
  
  <p>I can see it does pick up email although the email address does not display in METADATA:</p>
  
  <pre><code>object(Facebook\Authentication\AccessTokenMetadata)#17 (1) { ["metadata":protected]=&gt; array(7) { ["app_id"]=&gt; string(15) "1234565678" ["application"]=&gt; string(4) "PLFT" ["expires_at"]=&gt; object(DateTime)#21 (3) { ["date"]=&gt; string(26) "2017-06-11 10:47:32.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(3) "UTC" } ["is_valid"]=&gt; bool(true) ["issued_at"]=&gt; object(DateTime)#22 (3) { ["date"]=&gt; string(26) "2017-04-12 10:47:32.000000" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(3) "UTC" } ["scopes"]=&gt; array(2) { [0]=&gt; string(5) "email" [1]=&gt; string(14) "public_profile" } ["user_id"]=&gt; string(16) "36346346346346" } } 
  </code></pre>
  
  <p>Here is the script I am using:</p>
  
  <pre><code>&lt;?
  session_start();
  include 'system/db.php';
  require_once 'fb_connect/autoload.php';
  
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '346364326346346',
    'app_secret' =&gt; 'reyeryeryeryeerwyer346436',
    'default_graph_version' =&gt; 'v2.5',
  ]);
  
  $helper = $fb-&gt;getRedirectLoginHelper();
  
  try {
    $accessToken = $helper-&gt;getAccessToken();
  } catch(Facebook\Exceptions\FacebookResponseException $e) {
    // When Graph returns an error
    echo 'Graph returned an error: ' . $e-&gt;getMessage();
    exit;
  } catch(Facebook\Exceptions\FacebookSDKException $e) {
    // When validation fails or other local issues
    echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
    exit;
  }
  
  if (! isset($accessToken)) {
    if ($helper-&gt;getError()) {
      header('HTTP/1.0 401 Unauthorized');
      echo "Error: " . $helper-&gt;getError() . "\n";
      echo "Error Code: " . $helper-&gt;getErrorCode() . "\n";
      echo "Error Reason: " . $helper-&gt;getErrorReason() . "\n";
      echo "Error Description: " . $helper-&gt;getErrorDescription() . "\n";
    } else {
      header('HTTP/1.0 400 Bad Request');
      echo 'Bad request';
    }
    exit;
  }
  
  // Logged in
  echo '&lt;h3&gt;Access Token&lt;/h3&gt;';
  var_dump($accessToken-&gt;getValue());
  
  // The OAuth 2.0 client handler helps us manage access tokens
  $oAuth2Client = $fb-&gt;getOAuth2Client();
  
  // Get the access token metadata from /debug_token
  $tokenMetadata = $oAuth2Client-&gt;debugToken($accessToken);
  echo '&lt;h3&gt;Metadata&lt;/h3&gt;';
  var_dump($tokenMetadata);
  // Validation (these will throw FacebookSDKException's when they fail)
  $tokenMetadata-&gt;validateAppId('43141346436316'); // Replace {app-id} with your app id
  // If you know the user ID this access token belongs to, you can validate it here
  //$tokenMetadata-&gt;validateUserId('123');
  $tokenMetadata-&gt;validateExpiration();
  
  if (! $accessToken-&gt;isLongLived()) {
    // Exchanges a short-lived access token for a long-lived one
    try {
      $accessToken = $oAuth2Client-&gt;getLongLivedAccessToken($accessToken);
    } catch (Facebook\Exceptions\FacebookSDKException $e) {
      echo "&lt;p&gt;Error getting long-lived access token: " . $helper-&gt;getMessage() . "&lt;/p&gt;\n\n";
      exit;
    }
  
    echo '&lt;h3&gt;Long-lived&lt;/h3&gt;';
    var_dump($accessToken-&gt;getValue());
  }
  
  $_SESSION['fb_access_token'] = (string) $accessToken;
  print_r($_SESSION['fb_access_token']);
  
  
  // User is logged in with a long-lived access token.
  // You can redirect them to a members-only page.
  //header('Location: https://example.com/members.php');
  
  ?&gt;
  </code></pre>
  
  <p>Any idea as to how I can display user data around the website? </p>