我正在尝试将Instapaper API整合到我正在创建的应用中。阅读完整的API,需要使用OAuth。我准备好了OAuthConsumer库,这是我到目前为止的代码:
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:INSTAPAPER_API_CONSUMER_KEY
secret:INSTAPAPER_API_CONSUMER_SECRET];
NSURL *url = [NSURL URLWithString:instapaper_API_ACCESS_TOKEN_URL];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:@"POST"];
[request setParameters:[NSArray arrayWithObjects:
[OARequestParameter requestParameter:@"x_auth_mode" value:@"client_auth"],
[OARequestParameter requestParameter:@"x_auth_username" value:username.text],
[OARequestParameter requestParameter:@"x_auth_password" value:password.text],
nil]];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(didReceiveAccessToken:data:)
didFailSelector:@selector(didFailOAuth:error:)];
此后我唯一的问题是,在fetcher获取数据之后,没有选择器运行。我在同一个源文件中定义了选择器,但在OADataFetcher.m中定义了一些其他选择器:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request
response:response
data:responseData
didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400];
[delegate performSelector:didFinishSelector withObject:ticket withObject:responseData];
[ticket release];
}
有什么建议我应该做什么/我做错了什么?