我使用此代碼來檢查,如果用戶有一個開放的Facebook會話,也使我的應用程序空會話:的Facebook的Javascript SDK FB.getLoginStatus返回即使用戶連接
window.fbAsyncInit = function() {
FB.init({
appId : 'MY APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
function checkLoginFB() {
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
showLogout();
} else {
// no user session available, someone you dont know
showLogin();
}
});
}
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
}
但無論什麼(用戶是否登錄到Facebook並且允許我的應用程序) 我得到response.session的空值。有誰知道爲什麼?
只是爲了驗證你實際上是否改變了'我的應用ID'來反映你的實際應用ID是否正確? – Gabriel 2011-03-13 19:06:45
是的,我剛剛用這個帖子的'我的APP ID'。 – Zigglzworth 2011-03-13 22:11:56
這是怎麼回事?在現場或開發環境中? – Charlino 2011-03-16 20:09:34