【问题标题】:Readability API and RestKit - response status code 500可读性 API 和 RestKit - 响应状态码 500
【发布时间】:2012-08-16 23:20:31
【问题描述】:

你好我正在尝试实现Readability API 在我的应用程序中,但我得到的只是状态码 500 - “未知问题”。 我的响应正文是一个 html 页面,上面写着“Page unavalaivable”。

我正在使用 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];
}

非常感谢!

【问题讨论】:

    标签: iphone ios cocoa-touch oauth restkit


    【解决方案1】:

    您应该使用带有 RestKit 的 GCOAuth 包之一来帮助您简化事情。这是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];
    

    【讨论】:

    • 感谢您的回复。它确实有效 - 它显示状态代码 200(OK)。但是我无法提取 access_token。你能告诉我怎么做吗?再次感谢您。
    • 一旦你有了 NSURLRequest,你就可以通过 NSURLConnection 发送它并接收数据。 this previous answer 就是一个很好的例子。你最终得到一个字典,你从请求 accessToken 和 tokenSecret
    猜你喜欢
    • 2018-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    • 2011-12-21
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多