How to implement exit functions for the Facebook graphical API

I implemented the Facebook API in my iPhone app and I successfully posted it to the wall. But every time I finish my application and return, it saves my credentials (in Safari, I think it's a cookie). He asks for my permission with my previous credentials. But for now, I want my Facebook API to request a new username and password to request permission. I just want to exit my Facebook when I select a button in my application.

+2
source share
4 answers

How did you get into facebook in the first place? If you are using the facebook iOS SDK, you just need to call [facebook logout:self]; . Otherwise, if you use the Graph API yourself, you just need to clear the cookies and delete the access token.

+1
source
 fbGraph.accessToken = nil; NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (cookie in [storage cookies]) { NSString *domainName = [cookie domain]; NSRange domainRange = [domainName rangeOfString:@"facebook"]; if(domainRange.length > 0) { [storage deleteCookie:cookie]; } } 
+2
source

when you call the facebook button on this method in the last line and write this method [facebook logout]

+1
source
 NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { [cookies deleteCookie:cookie]; } 

These codes are sufficient to implement the exit functions of the system.

It works great on my application.

0
source

All Articles