我想在用户通过Facebook登录时收集一些信息。 除了用户生日,我能够获得所需的所有信息
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=first_name,last_name,birthday,email,gender');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfname = $graphObject->getProperty('first_name'); // To Get Facebook first name
$fblname = $graphObject->getProperty('last_name'); // To Get Facebook last name
$fbbday = $graphObject->getProperty('birthday'); // To Get Facebook birthday
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
$fgender = $graphObject->getProperty('gender'); // To Get Facebook gender
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['FIRST_NAME'] = $fbfname;
$_SESSION['LAST_NAME'] = $fblname;
$_SESSION['BIRTHDAY'] = $fbbday;
$_SESSION['EMAIL'] = $femail;
$_SESSION['GENDER'] = $fgender;
checkuser($fbid,$fbfname,$femail);
/* ---- header location after session ----*/
header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl(array('scope' => 'email'));
header("Location: ".$loginUrl);
}
?>
我做错了什么?
答案 0 :(得分:0)
我做错了什么?
您不是要求用户获得访问其生日所需的许可。
https://developers.facebook.com/docs/facebook-login/permissions#reference-user_birthday
答案 1 :(得分:0)
您没有要求正确的许可:
$loginUrl = $helper->getLoginUrl(array('scope' => 'email,user_birthday'));
顺便说一下,请务必使用App Admin进行测试。 user_birthday
需要在每个人都可以使用之前进行审核:https://developers.facebook.com/docs/facebook-login/review