-1

I am using the MGTWitter engine, and have had success authenticating and posting tweets.

Here's what I'm stuck on: I would like to store the twitter username and store it, so that I can display it on the view before a user posts a tweet.

I've scoured the web and can't find the right method. Should I somehow be storing the username in the storeCachedTwitterOAuthData delegate method?

Any help would be greatly appreciated.

-SD

SD.
  • 37
  • 6

1 Answers1

1

If I am not wrong, the purpose of using OAuth, is not to keep the username or password in client side, in this case your iOS app.

It seems like you are also using web view based authentication, such as what Twitter-OAuth-iPhone by Ben Gottlieb(https://github.com/bengottlieb/Twitter-OAuth-iPhone) provides.

If you do, you should implement storeCachedTwitterOAuthData delegate method to save username. Above mentioned Twitter-OAuth-iPhone library provides nice example for web based authentication and example implementation of - (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username;

petershine
  • 3,190
  • 1
  • 25
  • 49
  • Thanks for the reply, Peter. I am indeed using the library by Ben Gottlieb (and amalgamated by Matt Gemmel) that you mention, and have implemented the two delegate methods you mention. The examples that I have seen all store the OAuth token (in the form of "authData", but not the username specifically, and I don't know how to retrieve the username. – SD. Feb 06 '11 at 14:51
  • Guess my answer wasn't really helpful. I admit, I haven't used this for sometime since I have begun to use xAuth instead. As a solution to get Twitter name of the app user, I used `- (NSString *)getUserInformationFor:(NSString *)usernameOrID` for your app user him of herself. Returned dictionary object contains the object with the key 'screen_name' which is the actual Twitter name in his or her account. Hope this helps. In conclusion, you should make your own procedure to get the Twitter name of authenticated app user. Try getting user information at `storeCachedTwitterOAuthData` – petershine Feb 06 '11 at 17:07
  • Thanks very much, Peter. I ended up using storeCachedTwitterOAuthData and also check [_engine username] to see if that value was NULL or not, and controlled accordingly. Thanks! – SD. Feb 07 '11 at 03:36
  • I am also glad that I could help you about the exact same issue I had to deal with. Hope you will succeed in your iOS project – petershine Feb 07 '11 at 07:08