Reputation: 794
I'm using xauth, and can successfully get an access token, but can't work out how to get the logged in user's id and name (from the token? or something to do with the delegate method accessTokenReceived?)
I have the username from when the user entered it to log in, so could use this to get the id... but this could also have been an email address, so it starts to get messy.
according to the twitter api, getting an access token the normal way with http would give a response like this:
oauth_token=819797-torCkTs0XK7H2A2i1ee5iofqkMC4p7aayeEXRTmlw&oauth_token_secret=SpuaLXRxZ0gOZHNQKPooBiWC2RY81klw13kLZGa2wc&user_id=819797&screen_name=episod
which includes the id and name. is this information available somehow with the MGTwitterEngine accessTokenReceived method? thanks.
Upvotes: 1
Views: 1170
Reputation: 11834
The MGTWitterEngine has a few delegate methods, one of these methods is the following:
- (void)OAuthTwitterController:(SA_OAuthTwitterController *)controller
authenticatedWithUsername:(NSString *)username {
NSLog(@"%@", username);
}
As you can see, this method always returns the screenname upon succesful login (even when logging in using an email address). The screenname can be used in other twitter calls, e.g. (lets assume the screenname id_aa_carmack was returned):
http://api.twitter.com/1/users/profile_image/id_aa_carmack.json
Another example:
http://api.twitter.com/1/users/show.json?screen_name=id_aa_carmack
I hope this helps :)
Upvotes: 2