0

適切なページにリダイレクトされない理由がわかりません。それは確かに存在します。私をリダイレクトする代わりに、画面がポップアップし、1 秒後に消えます。

<div id='fb-root'></div>
<script>
window.fbAsyncInit = function() 
{
    FB.init({
        appId: 'ID', 
        status: true, 
        cookie: true, 
        xfbml: true
    });

    FB.Event.subscribe('auth.login', function(response) 
    {
        window.location = '/fb_redirect.php';
    });
};

(function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = '//connect.facebook.net/en_US/all.js#xfbml=1&appId=ID';
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

<div class='fb-login-button' data-show-faces='false' scope='email' data-width='200' data-max-rows='1'></div>
4

1 に答える 1

0

を実行する代わりにFB.Event.subscriber、次のことを試してください。

FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        if ( typeof response != 'undefined' && typeof response.authResponse != 'undefined' ) {
            window.location = '/fb_redirect.php';
        }
    } else if (response.status === 'not_authorized') {
        // the user is logged in to Facebook, 
        // but has not authenticated your app
    } else {
        // the user isn't logged in to Facebook.
    }
});

ユーザーがログインしている場合、関数は戻りconnected、必要なページにリダイレクトします。FB.Event.subscriber初めてログインする必要があるユーザーのために関数をそこに保持することができ、上記のコードはユーザーを返すために機能します。

于 2013-03-20T11:11:53.970 に答える