2015-09-16 18 views
-1

我正在制作一个网站,通过他们的Facebook账户登录。无法获取用户通过我的网站的fb账户登录的电子邮件

我能够获取名称和用户图像,但我没有收到用户的电子邮件。电子邮件正在返回未定义状态。我对Facebook登录代码:

window.fbAsyncInit = function() { 
FB.init({ 
     appId  : 'XXXXXXXXXXXXXXXX', // Set YOUR APP ID 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
}); 
FB.Event.subscribe('auth.authResponseChange', function(response) 
{ 
    if (response.status === 'connected') 
{ 
document.getElementById("message").innerHTML += "<br>"; 
}  
else if (response.status === 'not_authorized') 
{ 
} 
}); 
}; 
function Login() 
{ 
FB.login(function(response) { 
if (response.authResponse) 
{ 
getUserInfo(); 
getPhoto(); 
} else 
{ 
console.log('User cancelled login or did not fully authorize.'); 
} 
},{scope: 'email,user_photos,user_videos'}); 
} 
function getUserInfo() { 
FB.api('/me', function(response) { 
var str="You have succesfully logged in<br>"; 
var name=response.name; 
var email=response.email; 
console.log(name+email); 
}); 
$(document).ajaxStop(function(){ 
    window.location.reload(); 
}); 
    } 
    function getPhoto() 
    { 
FB.api('/me/picture?type=normal', function(response) { 
var str="<br/><b>Pic</b> : <img src='"+response.data.url+"'/>"; 
$('#getphoto').html(str); 
}); 
} 
function Logout() 
{ 
FB.logout(function(){document.location.reload();}); 
} 
// Load the SDK asynchronously 
(function(d){ 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
}(document)); 

我试着通过堆栈溢出和developers.facebook.com提到的所有方式获得的电子邮件,但没有成功。

触发的Facebook登录:

<img src='img/fblogin.jpg' onclick='login()'> 

我试图 for (key in response){ alert("response["+ key +"]="+ response[key]); } 它返回名称和ID提醒响应特性不支持电子邮件

+0

我试图通过(钥匙提醒响应特性作为响应){ alert(“response [”+ key +“] =”+ response [key]); }它返回的名称和编号不是电子邮件 –

回答

0
I think issue is on your app that you have created on here https://developers.facebook.com/apps/ 

can you please make below changes first ? 

login in https://developers.facebook.com/apps/ and open your app. 

Click on "Status & Review" then find this " 
Do you want to make this app and all its live features available to the general public?" make it yes. 

After that check did you get email or not and let me know. 
+0

我已经做到了。 Fb也显示完整的绿色信号(直播和悬停在所有用户信息上)。 –

+0

在我的批准项目fb显示电子邮件,公开个人资料,用户朋友 –

+0

好的,所以你可以尝试登录为另一个电子邮件地址,并检查是否收到电子邮件。因为有一段时间用户使他/她的个人资料隐藏了电子邮件。 –

相关问题