facebook FB.Event.subscribe('auth.authResponseChange')无效

Dez*_*zue 7 html javascript facebook

对于我的生活,我无法使用Event.subscribe('auth.authResponseChange')来工作.见下面的代码

  <div id="fb-root">
    </div>
    <script>
        window.fbAsyncInit = function () {
            FB.init({
                appId: 'XXXXXXXXXXXXXXX', // App ID
                channelUrl: 'http://XXXXXXXX.us/', // Channel File
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });

            FB.Event.subscribe('auth.authResponseChange', function (response) {
                alert('The status of the session is: ' + response.status);
            });
        };


        // 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));
    </script>
    <div class="fb-login-button" data-size="xlarge" scope="email" data-show-faces="false"
        data-width="400" data-max-rows="1" autologoutlink="true">
        Login with Facebook</div>
Run Code Online (Sandbox Code Playgroud)

登录按钮呈现.我也可以退出 唯一的问题是auth.response更改没有触发,我没有收到"消息"弹出窗口

小智 -4

您的 fbAsyncInit 函数是异步调用的,因此您不会看到任何警报消息。尝试使用 console.log 来进行调试。