Why can't I log a user out of facebook in an AIR desktop application?
I'm building an AIR desktop app with facebook support using Adobe Flash builder. So far it's working alright, except for one detail, once a user logs in, that session stays open, even if 开发者_如何学Cthe logout button is pressed. My logout code look like so:
protected function logout():void {
FacebookDesktop.logout(handleLogout, APP_ORIGIN);
}
I set APP_ORIGIN to "http://www.facebook.com". I checked Adobe's documentation and they say: appOrigin:String (default = null) — (Optional) The site url specified for your app. Required for clearing html window cookie. But I don't know what that means, what is the 'site url specified by my app'? Where do I get it? Sorry if this is a noob question.
After trying 20 different workarounds, the only solution that worked for me is: http://nekyouto-tech.blogspot.de/2012/09/fb-adobe-air-logout-bug.html
var uri:String = APP_ORIGIN;
var params:URLVariables = new URLVariables();
params.next = uri;
params.access_token = FacebookDesktop.getSession().accessToken;
var req:URLRequest = new URLRequest("https://www.facebook.com/logout.php");
req.method = URLRequestMethod.GET;
req.data = params;
var netLoader:URLLoader = new URLLoader();
netLoader.load(req);
FacebookDesktop.logout(handleLogout, APP_ORIGIN);
This is what worked for me
public function facebookLogout():void {
if (FacebookDesktop.getSession() != null) {
var uri:String = "http://www.facebook.com/";
var params:URLVariables = new URLVariables();
params.next = uri;
params.access_token = FacebookDesktop.getSession().accessToken;
var req:URLRequest = new URLRequest("https://www.facebook.com/logout.php");
req.method = URLRequestMethod.GET;
req.data = params;
var netLoader:URLLoader = new URLLoader();
netLoader.load(req);
FacebookDesktop.logout(handleLogout, uri);
}
}
Nevermind, I figured it out, what I did was define my app origin as localhost and now it works.
精彩评论