Objective-C: How to use xAuth?
I'm relatively new to Objective-C and am completely new to xAuth. Can somebody show me how or lead me to a tutorial to get a request access token pair and make a request to a URL given username
, password
, consumer_key
, and consumer_secret
?
I'm really foggy with this, and I don't even know why I get a access token pair (why two tokens, and how to both 开发者_C百科of them come into play?). Also, I already looked through a bunch of tutorials, but all of the good ones are for Twitter, and use some kind of Twitter engine. (I'm using xAuth for Foursquare, and their documentation can be found here.)
Thanks!
MGTwitterEngine is a great place for example code. You can use the OAuthConsumer project to help making xAuth calls.
If you checkout MGTwitterEngine.m (shown on Github) you can see in the function
- (NSString *)getXAuthAccessTokenForUsername:(NSString *)username password:(NSString *)password
creates an OAConsumer
object with consumerKey and Secret and then creates an OAMutableURLRequest
object, you'd use Foursquare's info there.
You should then be able to create a NSURLConnection
with that request and then get your results in your standard delegate method, a la URL Loading System
精彩评论