1

Hello I am trying to implement Readability API in my app, but all I get is status code 500 - "unknown problem". My response body is a html page saying "Page unavalaivable".

I am using RestKit.

Here is how I try to connect:

-(void)sendRequests
{
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"myconsumerkey", @"oauth_consumer_key",
                            [NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]], @"oauth_timestamp",
                            [self uuid], @"oauth_nonce",
                            @"HMAC-SHA1", @"oauth_signature_method",
                            @"mysecretkey", @"oauth_consumer_secret",
                            @"1.0",@"oauth_version",
                            @"username", @"x_auth_username",
                            @"password", @"x_auth_password",
                            @"client_auth", @"x_auth_mode", nil];
    RKClient *client = [RKClient clientWithBaseURL:[NSURL URLWithString:@"https://www.readability.com/api/rest/v1"]];

    [client post:@"/oauth/access_token" params:params delegate:self];
}

Thank you a lot!

DevFly
  • 413
  • 3
  • 15

1 Answers1

1

You should use one of the GCOAuth package with RestKit to help simplify things for you. Here is an example they give for doing xauth with GCOAuth:

NSURLRequest *xauth = [GCOAuth URLRequestForPath:@"/oauth/access_token"
POSTParameters:[NSDictionary dictionaryWithObjectsAndKeys:
username, @"x_auth_username",
password, @"x_auth_password",
@"client_auth", @"x_auth_mode",
nil]
host:@"api.twitter.com"
consumerKey:CONSUMER_KEY
consumerSecret:CONSUMER_SECRET
accessToken:nil
tokenSecret:nil];
Mark S.
  • 3,849
  • 4
  • 20
  • 22
  • Thanks for the response. It really works - it shows status code 200 (OK). However I'm not able to extract the access_token. Can you show me how to do it? Thank you again. – DevFly Aug 16 '12 at 15:58
  • Once you have the NSURLRequest, you send it via NSURLConnection and receive the data. A good example of this is in [this previous answer](http://stackoverflow.com/questions/4456966/how-to-send-json-data-in-the-http-request-using-nsurlrequest). You end up with a dictionary that you request the accessToken and tokenSecret from – Mark S. Aug 16 '12 at 16:22