我想获取用户的推文
以下代码使用twitter API并获取用户的推文
但是日志输出data:{"errors":[{"message":"SSL is required","code":92}]}
- (void)getJSON
{
NSURL* url = [NSURL URLWithString:@"http://api.twitter.com/1.1/statuses/user_timeline.json"];
OAConsumer* consumer = [[OAConsumer alloc]initWithKey:kTwitterAPIKey secret:kTwitterAPISecret];
OAMutableURLRequest* request = [[OAMutableURLRequest alloc]initWithURL:url consumer:consumer token:_responseToken realm:nil signatureProvider:nil];
[request setHTTPMethod:@"POST"];
OADataFetcher* fetcher = [[OADataFetcher alloc]init];
[fetcher fetchDataWithRequest:request delegate:self didFinishSelector:@selector(getData:didFinishWithData:) didFailSelector:@selector(failedToGet:didFailWithError:)];
}
- (void)getData:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data
{
NSString* responseBody = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"data:%@", responseBody);
}
我需要使用SSL吗?我如何使用SSL?
你有什么想法吗?
答案 0 :(得分:3)
在您的网址中使用“https”:
https://api.twitter.com/1.1/statuses/user_timeline.json
这必须足以解决问题。