我想獲取用戶的推文。
以下代碼使用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?
你有什麼想法嗎?
嘗試將http://更改爲https:// – Bimawa 2014-09-25 04:36:29
謝謝。它正常運行。 – 2014-09-25 04:39:33