调用FB.logout()时没有访问令牌错误

Fbk*_*Dev 4 facebook logout

我已经升级了我的js FB Connect到oauth版本,当我尝试使用FB.logout()方法以编程方式从FB注销时,我收到的错误就像

"没有访问令牌的FB.logout()调用"

这有什么问题?我在这里看到一个线程,但它对我不起作用.如果有人为此找到解决方案,请帮助我.谢谢.

tim*_*own 8

这就是我以前用过的东西.

//check if logout is 
FB.getLoginStatus(function(ret) {
    /// are they currently logged into Facebook?
    if(ret.authResponse) {
        //they were authed so do the logout
        FB.logout(function(response) {
           //do your stuff here.
        });
    } else {
       ///do something if they aren't logged in
       //or just get rid of this if you don't need to do something if they weren't logged in
    }
});
Run Code Online (Sandbox Code Playgroud)


Cli*_*ote 0

我遇到过这个问题并解决了它。

当用户已经注销并且我再次尝试 fb.logout() 方法时,这种情况发生在我身上。似乎在下面的代码中:

FB.logout(function(response)
  {
     console.log(response.status);
  }
);
Run Code Online (Sandbox Code Playgroud)

response.status即使用户因某些缓存问题或其他错误而注销,也会显示“已连接”。因此,最好用它来authResponse确定用户是否登录。即:

FB.logout(function(response)
  {
     if (! response.authResponse)
       //disable logout button
  }
);
Run Code Online (Sandbox Code Playgroud)