为什么FB.Event.subscribe在I'我已从脸书注销



如果我登录到facebook,testAPI()函数会按预期触发,但当我注销facebook并刷新init代码所在的页面时,什么都不会发生。我的控制台应该记录"未登录"或"未授权",但它没有。我试过清除缓存,但不起作用。

FB.Event.subscribe('auth.authResponseChange', function(response) {
     //this works 
      testAPI();
    } else if (response.status === 'not_authorized') {

      console.log("not authorized");
    } else {

      console.log("not logged in");
    }
  });
var testAPI = function() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
    });
  };

auth.authResponseChange仅在状态实际更改时才会触发,在您的情况下,它永远不会更改。

您想要的是使用FB.getLoginStatus

最新更新