2014-09-25 112 views
1

我想获取用户的推文。
以下代码使用twitter API并获取用户的推文。
但日志输出data:{"errors":[{"message":"SSL is required","code":92}]}Twitter API返回错误:需要SSL(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?
你有什么想法吗?

+7

尝试将http://更改为https:// – Bimawa 2014-09-25 04:36:29

+0

谢谢。它正常运行。 – 2014-09-25 04:39:33

回答

2

使用 “https” 开头的网址:

https://api.twitter.com/1.1/statuses/user_timeline.json 

那一定是足以解决问题。

+0

爱德华多实际上解决了原来海报一年前提出的问题,但在评论中首先发布它的人可能是有礼貌的。 – AHiggins 2015-07-27 14:44:43

+0

@ Ahiggins哦!我很抱歉。我没有注意到Bimawa的回应。我没有看到答案,所以我认为它还没有解决。 – 2015-07-27 15:29:48

+0

没问题!这就是为什么我提到它 - 我不确定你是否注意到了。 – AHiggins 2015-07-27 15:55:26