0

我正在使用Facebook登錄mvc3項目。我試圖獲取用戶的電子郵件地址。這裏是我的代碼: -Facebook登錄回覆沒有返回電子郵件地址

function getFaceBook() { 
    FB.init({ 
     appId: 'xxxx', // App ID 
     channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File 
     status: true, // check login status 
     cookie: true, // enable cookies to allow the server to access the session 
     xfbml: true, 

    }); 
    FB.login(function (response) { 

     FB.api('/me', function (response) { 
      alert(JSON.stringify(response)); 
      alert(response.email) 
      var Profile = "http://graph.facebook.com/" + response.id + "/picture"; 
      }); 
    }); 

所有工作正常。但迴應總是返回電子郵件undefine.Before上週前它工作正常。 誰能告訴我我錯過了什麼。提前致謝。

+0

你有權限來獲取用戶的電子郵件? –

+0

嗨@Sahil是的,我有這個權限。 – user1649879

+0

但我不能在你的代碼中看到。看看我的答案,看看如何設置燙髮 –

回答

0

嘗試這樣的:

FB.login(function (response) { 
    if(response.authResponse) 
    { 
     FB.api('/me', function (response) { 
     alert(JSON.stringify(response)); 
     alert(response.email) 
     var Profile = "http://graph.facebook.com/" + response.id + "/picture"; 
     }); 
    } 
    else 
    { 
     // not authorize 
    } 
},{scope: 'email'}); 
相關問題