可读性API和RestKit - 响应状态代码500

时间:2012-08-16 11:58:30

标签: iphone ios cocoa-touch oauth restkit

您好我正在尝试实施Readability API 在我的应用程序中,但我得到的是状态代码500 - “未知问题”。 我的回复正文是一个html页面,上面写着“页面无法容纳”。

我正在使用RestKit。

以下是我尝试连接的方式:

-(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];
}

非常感谢你!

1 个答案:

答案 0 :(得分:1)

您应该使用其中一个GCOAuth软件包和RestKit来帮助您简化操作。这是一个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];