1

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

{"error":{"lang":"en-US","description":"请提供有效凭据。OAuth oauth_problem=\"signature_invalid\", realm=\"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];

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

4

1 回答 1

0
"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

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

于 2014-05-30T13:35:29.090 回答