Hi Randy,
We recommend you use an already created library to get OAuth working first.
That way you can see the calls being made, the sort of responses you should
be getting and giving you something to compare your code to. We have a list
of OAuth libraries in different languages (including objective C) on our
developer resources site: http://dev.twitter.com/pages/oauth_libraries
Best,
Matt
On Wed, Jul 14, 2010 at 6:52 AM, Rendy Pranata rendy.pran...@gmail.comwrote:
Hi,
I tried to do the request token out from basic, not using any
framework, like MGTwitter, or anything like that. I used objective C
for iPhone for development.
Things that still confused me is, I always get an error
{
NSErrorFailingURLKey = https://api.twitter.com/oauth/
request_token;
NSErrorFailingURLStringKey = https://api.twitter.com/oauth/
request_token;
NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork
Code=-1012 \The operation couldn\U2019t be completed.
(kCFErrorDomainCFNetwork error -1012.)\ UserInfo=0x783b940 {};
}
I assumed that it is because that the request has not reached your
server yet? cause I was expecting that i got the nice result, saying
that I have a problem with the authentication, or some sort? like
http://oauth.net/core/1.0/#auth_step1
If the request fails verification or is rejected for other reasons,
the Service Provider SHOULD respond with the appropriate response code
as defined in HTTP Response Codes (HTTP Response Codes). The Service
Provider MAY include some further details about why the request was
rejected in the HTTP response body as defined in Service Provider
Response Parameters (Service Provider Response Parameters).
That was from the OAuth documentation, and because I received an
error, not a error response, can I assume that the problem is in my
code?
NSMutableString *strings = [[NSMutableString alloc] init];
[strings appendString:@OAUTH ];
[strings appendString:@oauth_nonce=\];
[strings appendString:[signatures objectForKey:@oauth_nonce]];
[strings appendString:@\, oauth_callback=\];
[strings appendString:[signatures objectForKey:@oauth_callback]];
[strings appendString:@\, oauth_signature_method=\];
[strings appendString:[signatures
objectForKey:@oauth_signature_method]];
[strings appendString:@\, oauth_timestamp=\];
[strings appendString:[signatures objectForKey:@
oauth_timestamp]];
[strings appendString:@\, oauth_consumer_key=\];
[strings appendString:[signatures
objectForKey:@oauth_consumer_key]];
[strings appendString:@\, oauth_signature=\];
[strings appendString:[string stringForURLEncoding]];
[strings appendString:@\, oauth_version=\];
[strings appendString:[signatures objectForKey:@oauth_version]];
[strings appendString:@\];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@GET];
[req setValue:strings forHTTPHeaderField:@Authorization];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:req
returningResponse:response
error:error];
if (response ==nil)
NSLog(@%@, [error userInfo]);
else
{
NSLog(@REPONSE STATUS CODE %d, [response statusCode]);
NSLog(@CONTENT TYPE : %@, [[response allHeaderFields]
objectForKey:@Content-Type]);
NSString *payloadAsString = [[NSString alloc]
initWithData:responseData
encoding:NSUTF8StringEncoding];
NSLog(@CONTENT : %@, payloadAsString);
[payloadAsString release];
}
--
Regards,
Rendy Pranata
--
Matt Harris
Developer Advocate, Twitter
http://twitter.com/themattharris