2

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);
}
4

1 に答える 1

1

次のようなことを試してみてください。

https://gist.github.com/3370553

または、AuthorizeFacebook を JS API の「FB.login」に置き換えることもできます。

于 2012-08-16T16:20:36.113 に答える