我使用AFNetworking从我的iOS应用程序中获取JSON值我已经测试了我的代码到这个链接http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json然后我的代码工作正常.但当我使用http://www.fr20.wearedesigners.net/WADMac/tourism/fetchGuideListAndroid.php此链接检索数据时,我会得到以下错误,请在下面找到我使用的代码.请帮助我从我的URL检索数据
-(void) retriveData
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setValue:@"text/html" forHTTPHeaderField:@"Content-type"];
[manager GET:@"http://www.fr20.wearedesigners.net/WADMac/tourism/fetchGuideListAndroid.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
Run Code Online (Sandbox Code Playgroud)
错误日志
2014-07-19 18:36:01.107 WADTourisum[3000:60b] Reachability Flag Status: -R ------- networkStatusForFlags
2014-07-19 18:36:01.768 WADTourisum[3000:60b] Error: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0xa05c4e0 {NSErrorFailingURLKey=http://www.fr20.wearedesigners.net/WADMac/tourism/fetchGuideListAndroid.php, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x8d8ba40> { URL: http://www.fr20.wearedesigners.net/WADMac/tourism/fetchGuideListAndroid.php } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Type" = "text/html"; …Run Code Online (Sandbox Code Playgroud)