0

I am using as3-fb-api which connects to js-api for a flash app. it works fine: login, get friends profile pics, logout, repeat.

BUT if the user opens a second browser tab pointed to facebook.com, and uses it to logout of facebook, then returns to my app, and hits the logout button which calls Facebook.logout(), the problems begin.

my app listens for:

Facebook.addJSEventListener( 'auth.statusChange'       , om__statusChange       ) ;
Facebook.addJSEventListener( 'auth.authResponseChange' , om__authResponseChange ) ;
Facebook.addJSEventListener( 'auth.login'              , om__login_noticed      ) ;
Facebook.addJSEventListener( 'auth.logout'             , om__logout_noticed     ) ;

Ideally I would expect that the Facebook.logout() would call the js, which would ajax the fb servers, to discover that the user is already out, and return the message for the app to handle.

In my firebug debugger, I see that the facebookjsbridge: logout function is called, but its callback, FBAS.handleUserLogout, is not called, and none of the eventlisteners are called either.

So what is the appropriate way to synch my app with the servers?

dsdsdsdsd
  • 2,880
  • 6
  • 41
  • 56

1 Answers1

0

after several days of trying various techniques, this is what I have come up with BUT IT IS HACKish

the problem was: if user is logged into my facebook app via as3-fb-api:Facebook.login(...), and then goes to another browser tab, opens facebook.com there, logs out there, and then returns to my app and messes with it, my app becomes out-of-synch with facebook.

So to solve this issue I now have any and all Facebook.api calls to look for this failure:

{ error , [object Object] , object
    { code , 190 , number
      message , Error validating access token: The session is invalid because the user logged out. , string
      type , OAuthException , string
      error_subcode , 467 , number          
     }
}
// I may discover later that there are other types of failures 
//    that I will need to catch as well.

If any calls return with this error, the app reloads itself (I use a External-Interface call to js to handle the reload).

Furthermore, I have added a routine to my LOGOUT button to use this system. Originally when a user pressed the LOGOUT button, I would simply call Facebook.logout(...), but that fails IF the user has already logged out ... the Facebook.logout(...) does not even call the callback with an error message, so the app has no means to discover the out-of-synch problem.

So now when a user presses the LOGOUT button, the app first calls Facebook.api("/me/" , ... ). WHY? because that api call WILL return an error message (or success message) even if the user has logged out via another browser tab. And if this api call returns a failure message/object, then I divert the app to the reload phase, otherwise I continue, normally, with Facebook.logout(...)

dsdsdsdsd
  • 2,880
  • 6
  • 41
  • 56