Mgtwitter engine Login And logOut
Hello I am using MGTwitterEngine to create twitter app.I created different views for followers list, user time line and so on... Once I login It will save user credentials with following code
- (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: data forKey: @"authData"];
[defaults synchronize];
}
- (NSString *) cachedTwitterOAuthDataForUsername: (NSString *) username
{
return [[NSUserDefaults standardUserDefaults] objectForKey: @"authData"];
}
And I am passing consumer key and secret in view did appear . My question is should I write this consumer key and t开发者_开发问答his user credential code in all view.. or I can do it some other way? And how to logout from twitter?
you should delete cookies for log out thing..
like this..
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
NSString* domainName = [cookie domain];
NSRange domainRange = [domainName rangeOfString:@"twitter"];
if(domainRange.length > 0)
{
[storage deleteCookie:cookie];
}
}
I define consumer secret and key as a constant, they are static, so I just have to import a header, or even better put them in a constants.h and import with the prefix file in all files.
Logging out:
- Logout using MGTwitterEngine ?
- how to logout from Twitter in iPhone.I am using OAuth+MGTwitterEngine Library, there is a clearAccessToken method in the engine class.
精彩评论