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
没什么大不了的: