facebook api没有回复电子邮件

use*_*343 4 facebook facebook-graph-api facebook-javascript-sdk

我正在尝试使用facebook api返回用户的电子邮件地址.几天前它工作正常,但今天停止工作,不知道为什么.

所以首先我得到访问令牌:

FB.login(response => {
    if (response.authResponse) {
      resolve(response.authResponse.accessToken);
    } else {
      reject({
        error: 'User cancelled login or did not fully authorize.'
      });
    }
  }, {
    scope: 'public_profile,email'
  });
Run Code Online (Sandbox Code Playgroud)

然后我尝试获取用户数据

FB.api('/me', {fields: 'first_name,last_name,email'}, function(response) {
  console.log(response);
});
Run Code Online (Sandbox Code Playgroud)

但我只获取first_name和last_name的数据.没有电子邮件.

此外,当我要求权限时,它会给我发送电子邮件,但正如我所说,电子邮件不会被退回.

FB.api('/me/permissions', function(response) {
  console.log(response);
});
Run Code Online (Sandbox Code Playgroud)

有谁知道会出现什么问题?

顺便说一句:我使用的是API v2.4.

sti*_*nux 16

FB.api('/me?fields=email,name', function(response) { /* stuff here */ });
Run Code Online (Sandbox Code Playgroud)

尝试将返回字段添加到您的请求中.


N N*_*Nem 5

我知道这是个老问题,但是如果有人仍在寻找答案,那么以下解决方法对我有用。

您需要在 scope 中添加电子邮件 scope="public_profile,email"

<fb:login-button  scope="public_profile,email" autologoutlink="false" onlogin="OnRequestPermission();"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)