0

我不知道我的脚本发生了什么,它运行良好,然后它突然不返回电子邮件(返回未定义),但名字、姓氏和用户名工作正常。

这是代码

    <script type="text/javascript">


      // initialize the library with the API key

      FB.init({  appId: 'XXXXXXXXXX',status: true, cookie: true, xfbml: true, oauth: true });

      function login() {
          FB.login(function (response) {
              if (response.authResponse) {
                  console.log('Welcome!  Fetching your information.... ');

                  FB.api('/me', function (response) {

                      console.log('Good to see you, ' + response.name + '.email :' + response.email);
                      console.log('Good to see you, ' + ",gender:" + response.gender + "another : " + response.first_name);
                      console.log('Good to see you, ' + response.username + '.last_name :' + response.last_name);
                    //  console.log('Good to see you, ' + response);
                  }, { scope: 'email' });
              } else {
                  console.log('User cancelled login or did not fully authorize.');
              }
          });
      }
  </script>

我没有改变任何东西,可能是什么问题?

4

1 回答 1

2

要获取电子邮件,{ scope: 'email' }需要传递给FB.login,而不是作为参数传递给FB.api

FB.login(function (response) {
   ...
}, { scope: 'email' });
于 2012-12-17T08:32:15.560 回答