How to use yahoo boss search in ios

210 Views Asked by At

I am trying to use yahoo boss search but I am getting the following error

{"error":{"lang":"en-US","description":"Please provide valid credentials. OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}}

I am using following code to initiate the search request.

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

What is wrong with the above code. Please help.

1

There are 1 best solutions below

3
On
"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\""}

Your error says it all. As well as your code. Look at this line of code specifically

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

Or your Consumer object could hold invalid credentials here

initWithKey:Consumer-key
secret:Consumer-secret

In other words the authentication process is failing and returning the above errors