电子邮件不再通过Facebook oauth返回



我使用Oauth在我的网站上设置了Facebook注册/登录。它收回的数据之一是电子邮件,我将其包含在我对API 的调用范围中

http://www.facebook.com/dialog/oauth?client_id=[appID]&redirect_uri=[encoded_URL]&scope=email,user_likes,publish_stream

这会被重定向到一个带有以下代码的页面:

$code = $_GET['code'];
$tokenURL = "https://graph.facebook.com/oauth/access_token?client_id=[appID]&redirect_uri=[encoded_url]&client_secret=[secret_key]&code=" . $code;

// request access token
//use curl and not file_get_contents()
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $tokenURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$accessToken = curl_exec($ch);
curl_close($ch);
$graphURL = "https://graph.facebook.com/me?" . $accessToken;
// request user data using the access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $graphURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$tempUser = curl_exec($ch);
curl_close($ch);
//decode the json array to get user data
$user = json_decode($tempUser);
//store user data
$firstName = cleanWords($user->first_name);
$lastName = cleanWords($user->last_name);
$email = cleanEmail($user->email);

这以前很好,但后来我突然发现,即使用户在第一次使用该应用程序时允许提供电子邮件,JSON对象中也不再返回电子邮件。API是否发生了变化,因此现在需要对电子邮件进行不同的处理?我看到一篇帖子说,如果用户在用户设置中没有明确允许与应用程序共享电子邮件,那么它将不会被返回,但我在我的帐户中找不到任何这样的设置。

有人能告诉我该设置在哪里吗?这样我就可以测试是否存在问题,或者如果电子邮件不再以同样的方式访问,请告诉我,以及我需要更改什么?谢谢,

更新:我通过完全重写我的代码来使用新的Facebook API。

我已经验证了这不是代码问题:只是我测试的特定Facebook帐户有一些不同。还不确定是什么,但由于这是一个Facebook使用问题,而不是一个代码问题,这可以被认为是答案。

最新更新