我正在尝试通过 Javascript 启用 Facebook 登录到我的网站,但是当用户登录时,Facebook 弹出窗口不会关闭。相反,它显示以下消息:
作为登录过程的一部分,可能发生了错误。您可以关闭此窗口并尝试返回应用程序,但它可能会要求您再次登录。这可能是由于应用程序中的错误。
如果我再次单击登录按钮,一切正常。
这是我的代码:
// 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);
}