skip to Main Content

I have been read lot of topics about this, my email is set on primary but I can’t retrieve it with Facebook login SDK, I’m using scope as well but still no email.

I just don’t know where I should make changes right now lines that includes email scope.

if ( isset( $session ) ) {
  // graph api request for user data
  $request = new FacebookRequest( $session, 'GET', '/me?scope=email' );
  $response = $request->execute();
  // get response
  $graphObject = $response->getGraphObject();

  var_dump($graphObject);
        $fbid = $graphObject->getProperty('id');              // To Get Facebook ID
        $fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
        $femail = $graphObject->getProperty('email');    // To Get Facebook email ID
    /* ---- Session Variables -----*/
        $_SESSION['FBID'] = $fbid;           
        $_SESSION['FULLNAME'] = $fbfullname;
        $_SESSION['EMAIL'] =  $femail;
    /* ---- header location after session ----*/
  header("Location: /ico/");
} else {
  $loginUrl = $helper->getLoginUrl(array('scope' => 'email'));
 header("Location: ".$loginUrl);
}

2

Answers


  1. Scope is for login, you need to use the fields parameter:

    $request = new FacebookRequest($session, 'GET', '/me?fields=name,email');
    
    Login or Signup to reply.
  2. Some possible reasons:

    1. No Email address on account
    2. No confirmed email address on account
    3. No verified email address on account
    4. User entered a security checkpoint which required them to reconfirm their email address and they have not yet done so
    5. Users’s email address is unreachable
    6. If the user denies a permission, FB will not ask for the same permission again. For that you have to follow the re-request method.
    7. In certain cases I have also observed that if the user has logged in using their phone number, FB doesn’t return their email. However, I am not entirely sure about this scenario. There may be other factors affecting it.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search