jQuery facebook FB.Event.subscribe无效

时间:2017-11-04 05:05:08

标签: javascript jquery facebook facebook-graph-api facebook-events

我正在开发一个Facebook画布应用程序。

尝试登录并授权我的应用程序正常运行。

但是这种情况不起作用

  1. 我打开应用程序画布https://apps.facebook.com/ {appID}
  2. 点击Continue as按钮。
  3. 弹出窗口将显示,然后点击Continue As ...进行授权。
  4. 每件事看起来都很好,并且重定向到main.php
  5. 我转到app settings并删除我的应用。 更新:同时注销所有脸书;同样的结果!
  6. 这里我希望main.php提醒我用户删除了应用(已被授权)然后注销
  7. 没有任何事情发生,用户仍在页面中
  8. 这是我的代码

    // Load the SDK asynchronously
    (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/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }
        (document, 'script', 'facebook-jssdk'));
    
    window.fbAsyncInit = function () {
        FB.init({
            appId: '{APPID}',
            cookie: true, // enable cookies to allow the server to access
            // the session
            xfbml: true, // parse social plugins on this page
            version: 'v2.10', // use graph api version 2.8
            status: true,
            oAuth: true
    
        });
    
        //start coding
        // here trying all types of events subscribe to check if something
        // missing or if I am subscribing the wrong event
        FB.Event.subscribe('auth.authResponseChange', function (response) {
            alert("authResponseChange=" + response);
        });
    
        FB.Event.subscribe('auth.login', function (response) {
            alert("login=" + response);
        });
    
        FB.Event.subscribe('auth.statusChange', function (response) {
            alert("statusChange=" + response);
        });
    
        FB.getLoginStatus(function (response) {
            alert("getLoginStatus=" + response);
        });
    
    };
    
    function ReadPHPresponse(data, cmd) {
        //TODO
    }
    
    // end coding
    

    应用环境

    1. 应用程序处于开发模式
    2. 它在localhost WAMP上运行
    3. 尝试了一切禁用缓存的方法:WAMP,FB Calls,stats:true
    4. 在应用设置中,我选择canvas URLhttps://localhost/和应用域至localhost
    5. 在Facebook登录产品设置中,我还检查了有效的OAuth重定向URI 到https://localhost/
    6. FB API版本2.10
    7. 仍然没有触发,用户在删除我的应用时未注销。 如果我刷新main.php它的工作,用户就会被注销。

      我看到了以下类似的问题/答案,但没有一个能解决我的问题。

      why facebook FB.Event.subscribe is not working?

      how to detect log out from fb using JS SDK without refreshing the page

      FB JS-SDK cannot detect user logging out of FB directly

      How to detect user logging out of Facebook after logging into my app?

      我想知道什么是错的。

      谢谢

      更新:事件被解雇,但等了一个小时后;所以很可能是它的一些缓存问题!无法确定。

      UPDATE2:

      试图弄清楚什么是错的!我曾尝试过以下方法:

      1. jQuery从版本3降级为版本2
      2. 从Live Server加载我的应用,而不是localhost
      3. 检查app settings
      4. 检查console.log的所有内容;但没有错误返回!启用所有级别;我只收到[Violation] 'message' handler took 2450ms
      5. 检查Facebook平台,它是Healthy
      6. 将Facebook SDK加载到<head>sdk.js
      7. 尝试了不同的浏览器Chrome最新,FF最新和Edge最新和移动相同的结果。只有Edge返回:The code on this page disabled back and forward caching.我觉得无关紧要。
      8. 还尝试使用FB API V 2.8
      9. 仍然没有快乐

        以下是我的应用设置:

        App settings

        Deauthorize call back setting

        这太好笑了!请指教!

        谢谢

0 个答案:

没有答案