我通过各种文档和问题在这里讨论了stackoverflow,仍然无法弄清楚以下代码不会攻击任何fb.event.subscribe事件getloginstatus。

<div id="fb-root">
<script>
    (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));

    window.fbAsyncInit = function () {
        FB.init({
            appId: '{appID}', // App ID
            channelUrl: '{channelURL}', // Channel File
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true,  // parse XFBML
            oauth: true // enable OAuth 2.0
        });

        FB.Event.subscribe('auth.authResponseChange', function (response) {
            console.log(response);
        });

        FB.Event.subscribe('auth.login', function (response) {
            console.log(response);
        });

        FB.Event.subscribe('auth.statusChange', function (response) {
            console.log(response);
        });

        FB.getLoginStatus(function (response) {
            console.log(response);
        });
    };

</script>
</div>
<div>
    <div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1"></div>
</div> 
.

有帮助吗?

解决方案

如果其他人需要它,我发现了关于这个其他问题的问题的答案:

fb.event.subscribe不适用于auth.login,auth.logout和auth.statuschange

我进入Facebook并将Canvas URL更新为我的LocalHost URL,它工作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top