[twitter-dev] Re: Issues with OAuth

2010-07-20 Thread Rendy Pranata
I think its now fixed

On Jul 20, 3:41 pm, acreadinglist  wrote:
> Add me to the list.
>
> On Jul 19, 7:24 pm, JeremyE  wrote:
>
> > I'm having the same exact issue while developing my app. Internal
> > Server Error 500 from Twitter. Trying to get my access token.


[twitter-dev] Request token out from twitter

2010-07-14 Thread Rendy Pranata
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