我在使用 Facebook API 时遇到了一些问题,我正在通过 Javascript 请求对用户的某些信息的许可:
FB.login(function (response) {
if (response.authResponse) {
// authorized
} else {
// canceled
}
}, {scope: 'email,user_birthday,user_location'});
现在我想通过 PHP 获取用户的信息(当他被授权时):
$facebookUser = json_decode(file_get_contents('https://graph.facebook.com/' . $this->data['userid'] . '?access_token=' . $this->oathtoken . '&fields=id,name,location,gender,email,picture,birthday,link'));
一切都很好,除了 API 没有回馈用户的生日。即使我将我的生日隐私设置设为公开,它也不会显示。
所以:
echo $facebookUser['birthday']; // Gives an error, since this key does not exists
有人知道如何解决这个问题吗?