簡體   English   中英

使用Facebook JavaScript Java SDK訪問已登錄的用戶電子郵件

[英]Accessing logged in user email using facebook javascript sdk

我曾嘗試使用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>

名稱正確返回,但電子郵件未定義...。

scope參數中定義權限,就像:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM