Oauth signing

94 views
Skip to first unread message

naomi

unread,
Aug 12, 2010, 12:19:08 PM8/12/10
to ASIHTTPRequest
hi,

I am having to update my method of posting to Twitter now that OAuth
is going to be compulsory. Here is what has worked out for me: adding
library OAuthCore (http://bitbucket.org/atebits/oauthcore)

then:

NSString *consumerKey = @"consumer key"; //replacing
values accordingly
NSString *consumerSecret = @"consumer secret";
NSString *accessToken = @"access token";
NSString *accessTokenSecret = @"access secret";
NSString *method=@"POST";

NSURL *url = [NSURL URLWithString:@"http://twitter.com/statuses/
update.xml"]; // API call as appropriate

ASIFormDataRequest *request = [ASIFormDataRequest
requestWithURL:url];

[request setPostValue:[tweetTextField stringValue] forKey:@"status"];

[request buildPostBody];
NSData *body = [request postBody];

NSString *header = OAuthorizationHeader(url, method, body,
consumerKey, consumerSecret, accessToken, accessTokenSecret);

[request addRequestHeader:@"Authorization" value:header];



Hope this helps anyone else in this situation. This is working in Mac
OS X 10.5

Any comments on the subject are welcome

thanks.

Paul
Reply all
Reply to author
Forward
0 new messages