开发者

How to know if a user log out of Facebook, FB.Event.Subscribe not work

In my application, I need to catch the event of user log out of their Facebook while using my application, to force they login again. I have look through getLoginStatus JS API and FB.Event.subscribe . Function getLoginStatus works and I can make a polling, but I want to have a callback fu开发者_运维技巧nction (just like deauthorization callback function).

I think FB.Event.subscribe is what to do, but the event only gets fired when I refresh the page, which is not what I expected.

Is there any other way to identify that a FB user is still logged in, or is it absolutely needed to poll over time ?

CLARIFICATION: I want to get the event that user log out of his/her FB account, in order to log that user out of my application. My application is an iframe on Facebook page, it's not a social connect application.


I am not sure but may be the following code will help you.

At the time of loading your application just execute this script or js function as:

// FB logout
  logout: function() {
    FB.getLoginStatus(function(response) {
    if(response.session) {
        FB.logout(function(response) {
            return;
        });
    }
  });
  }

If the user is logged in Facebook, it will get the response.session. If the session is set, it will call FB.logout(), which will log out from Facebook. Even you can call this logout function at any where like by putting a link, which will execute this.


In the end, I must use an intermediate solution: instead of polling Facebook, I re-call FB.init() and FB.getLoginStatus() every time user try to access a function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜