2
我試圖啓用Facebook登錄到我的網站通過Javascript,但當用戶登錄時,Facebook彈出窗口不關閉。相反,它顯示以下消息:Facebook登錄錯誤(Javascript)
作爲登錄過程的一部分可能發生了錯誤。您可以關閉此窗口並嘗試返回到應用程序,但它可能會要求您再次登錄。這可能是由於應用程序中的錯誤。
如果我再次點擊登錄按鈕,一切工作正常。
這是我的代碼:
// 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));
// Init the SDK upon load
window.fbAsyncInit = function() {
var doLogin = function (response) {
url = '//'+window.location.hostname+'? access_token='+response.authResponse.accessToken;
window.top.location = url;
};
FB.init({
appId : 'MY_APP_ID', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true,
channelUrl : '//'+window.location.hostname+'/static/html/channel.html'
});
FB.Event.subscribe('auth.login', function(response) {
doLogin(response);
})
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
doLogin(response);
}
}, true);
}
登錄按鈕在哪裏? – CBroe 2012-08-10 09:09:51
沒什麼大不了的: