7

对于我的一生,我无法让 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>

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

4

2 回答 2

-1

你的代码看起来不错。

我会访问您的 Facebook 应用程序并特别检查 2 个设置。

  1. 检查“沙盒模式”-确保将其设置为“禁用”
  2. 检查您的站点 URL 和/或画布 URL - 确保将它们设置为您的域。(即,如果您在本地处理此问题,您的 url 应该类似于http://localhost:#####/##### 是您的端口。

希望有帮助。

于 2013-05-24T18:07:20.340 回答
-4

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

于 2012-08-07T00:32:17.620 回答