2

我曾尝试使用 javascritp sdk 教程使用 facebook 按钮进行登录,但我在电子邮件字段中不断收到“未定义”,并且该应用程序没有请求访问电子邮件..有什么想法我应该做不同的事情吗?这是我的代码...

     <script>


 window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '92',                        // App ID from the app dashboard
      channelUrl : '//om/fd/channel.php', // Channel file for x-domain comms
      status     : true,                                 // Check Facebook Login status
      cookie     : true,
      oauth:true,
      xfbml      : true                                  // Look for social plugins on the page
    });
  FB.Event.subscribe('auth.authResponseChange', function(response) {
      serverLogin();
    } else if (response.status === 'not_authorized') {
    FB.login(function(response){scope:'email'});
    } else {

FB.login(function(response){scope:'email'});
    }
  });
  };

  function serverLogin() {

    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me?fields=email,name', function(response) {
      console.log('Good to see you, ' + response.name + '.'+response.email);
      alert('Good to see you, ' + response.name + '.'+response.email);
    });
    //FB.logout();
  }
  // Load the SDK asynchronously

</script>
       <fb:login-button show-faces="false" width="100" max-rows="1"></fb:login-button>

名称返回正确,但电子邮件未定义....

4

1 回答 1

0

在参数中定义权限scope,就像:

<fb:login-button show-faces="false" scope="email" width="100" max-rows="1"></fb:login-button>
于 2013-09-01T08:38:49.840 回答