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'}); 
相关问题