FB.api没有收到电子邮件

时间:2016-01-19 09:39:29

标签: facebook-graph-api facebook-javascript-sdk

我开始使用FB.api通过Facebook帐户访问我的网站。

我通过这个代码直接从facebook开发人员那里使用令牌:

  window.fbAsyncInit = function() {
        FB.init({
            appId      : '00000000',
            xfbml      : true,
            cookie     : true,
            version    : 'v2.5'
        }); 

        FB.getLoginStatus(function(response) {
            statusChangeCallback(response);
        });
  };

  function statusChangeCallback(response) {
    console.log(response);
    if (response.status === 'connected') {
      testAPI();
    } else if (response.status === 'not_authorized') {
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    } else {
      document.getElementById('status').innerHTML = 'Please log ' +
        'into your Facebook.';
    }
  }

  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  function testAPI() {
    FB.api('/me?fields=last_name,gender,first_name,email', function(response) {
      console.log('Accesso effettuato: ' + response.first_name);
      document.getElementById('status').innerHTML =
        'Grazie per essere entrata, ' + response.last_name + response.email +
        "<img src='" + "https://graph.facebook.com/" + response.id + "/picture?type=large' alt='' />";
        console.log(JSON.stringify(response));
    });

  }

问题是没有显示任何字段的电子邮件!问题出在哪儿?! 我还检查我的Facebook帐户,使其他应用程序/网站的电子邮件可见,但没有任何变化! 这是错误的代码吗?!

1 个答案:

答案 0 :(得分:0)

如果您在使用电子邮件权限授权后甚至没有在API资源管理器中收到电子邮件,则只有2个选项可用于无法运行:

  • 您的电子邮件未经确认
  • 您正在使用Facebook登录的电话号码

检查您的用户设置。