Monday, 26 August 2013

OAConsumer API thows an error on receive data

OAConsumer API thows an error on receive data

I'm trying to fetch data using OAConsumer API. I tried the following code
which threw me an error.
-(void)performQuery
{
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:OAUTH_KEY
secret:OAUTH_SECRET];
NSURL *url = [NSURL
URLWithString:@"https://api.semantics3.com/v1/products"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil
realm:nil
signatureProvider:nil];
// use the default
method, HMAC-SHA1
[request setHTTPMethod:@"GET"];
[consumer release];
OARequestParameter * qParam = [[OARequestParameter alloc]
initWithName:@"q" value:@"{\"cat_id\":13658,\"model\":\"Satellite\"}"];
NSArray *params = [NSArray arrayWithObjects:qParam, nil];
[qParam release];
[request setParameters:params];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestDidFinishWithData:)
didFailSelector:@selector(requestDidFailWithError:)];
[request release];
}
The error is as follows:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[OAServiceTicket bytes]:
unrecognized selector sent to instance 0x1ed65bf0'
The error happens on this line: **NSString response= [[NSString alloc]
initWithData:data encoding:NSUTF8StringEncoding];
- (void)requestDidFinishWithData:(NSData *)data {
NSString *response= [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
//here do what you want with the response, I use SBJson to parse it.
NSLog(@"Request success!%@", response);
[responseBody release];
}
- (void)requestDidFailWithError:(NSError *)error {
NSLog(@"Request did fail with error: %@", [error localizedDescription]);
}
Any idea what I'm doing here?

No comments:

Post a Comment