【问题标题】:How to use yahoo boss search in ios如何在 ios 中使用 yahoo boss search
【发布时间】:2014-05-30 13:28:56
【问题描述】:

我正在尝试使用 yahoo boss search 但我收到以下错误

{"error":{"lang":"en-US","description":"请提供有效的 证书。 OAuth oauth_problem=\"signature_invalid\", 领域=\"yahooapis.com\""}}

我正在使用以下代码来发起搜索请求。

OAConsumer *consumer = [[OAConsumer alloc] initWithKey:Consumer-key
                                                secret:Consumer-secret];    
NSURL *url = [NSURL URLWithString:@"http://yboss.yahooapis.com/ysearch/images?q=obama&format=json&count=1"];

OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
                                                               consumer:consumer
                                                                  token:nil   // we don't have a Token yet
                                                                  realm:@"yahooapis.com"   
                                                      signatureProvider:nil]; // use the default method, HMAC-SHA1
[request prepare];
[request setHTTPMethod:@"POST"];


NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

上面的代码有什么问题。请帮忙。

【问题讨论】:

    标签: ios oauth yahoo-boss-api


    【解决方案1】:
    "error":{"lang":"en-US","description":"Please provide valid credentials. 
    OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}
    "error":{"lang":"en-US","description":"Please provide valid credentials.
    OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}
    

    你的错误说明了一切。以及您的代码。具体看这行代码

    token:nil   // we don't have a Token yet
    

    或者您的 Consumer 对象可能在此处持有无效凭据

    initWithKey:Consumer-key
    secret:Consumer-secret
    

    换句话说,身份验证过程失败并返回上述错误

    【讨论】:

    • 我检查了消费者密钥和密码是否正确,但仍然显示相同的错误。
    • 那么一定是令牌
    • 我解决了问题,只需在prepare 类的prepare 方法中将nonce 更改为[nonce URLEncodedString],其中添加了oauthHeader 字符串
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多