Twitter API返回错误:需要SSL(92)

时间:2014-09-25 04:32:32

标签: ios objective-c ssl twitter

我想获取用户的推文 以下代码使用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?
你有什么想法吗?

1 个答案:

答案 0 :(得分:3)

在您的网址中使用“https”:

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

这必须足以解决问题。