0

这可能是简单的,我只是俯瞰。我正在尝试使用AFNetworking从uStream的API中创建一个AFHTTPRequest。我应该得到一个JSON有效负载响应,它列出了uStream频道上的所有视频。这里是我的代码:AFNetworking与UStream频道的视频列表API请求

NSURL *url = [NSURL URLWithString:@"https://api.ustream.tv/channels/12321320/videos.json"]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 
operation.responseSerializer = [AFJSONResponseSerializer serializer]; 

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 
    NSLog(@"success"); 

} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    NSLog(@"failed"); 
}]; 

[operation start]; 

当在浏览器中测试但尝试使用AFNetworking时,一切都正常工作我得到一个NSURLErrorDomain失败。任何人有任何建议?

+1

我复制并粘贴了你的代码,它对我很好。 – Sandeep 2015-01-26 22:05:50

+0

你回复什么? – DJSK 2015-01-26 22:12:50

+1

我得到了相同的json响应。 – Sandeep 2015-01-26 22:13:17

回答

0

我的代码很好,但是我的iphone模拟器出现了问题。重置内容和设置的窍门。感谢k6sandeep的帮助。