2015-09-16 25 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

好的,所以你可以嘗試登錄爲另一個電子郵件地址,並檢查是否收到電子郵件。因爲有一段時間用戶使他/她的個人資料隱藏了電子郵件。 –

相關問題