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
Scope is for login, you need to use the fields parameter:
Some possible reasons:
re-request
method.