Reh*_*n K 8 json ios afnetworking afnetworking-2
我使用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";
Date = "Sat, 19 Jul 2014 13:05:32 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.2.17";
} }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
Run Code Online (Sandbox Code Playgroud)
Ven*_*kaT 37
它发生了
NSLocalizedDescription=Request failed: unacceptable content-type: text/html
Run Code Online (Sandbox Code Playgroud)
格式Content-Type"="text/html没有您的AFNetworking.
只要到Serilization->AFURLResponseSerialization.m,线215,并进行更改:
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
Run Code Online (Sandbox Code Playgroud)
它会对你有用.
更新的版本可能在223行上有代码.
| 归档时间: |
|
| 查看次数: |
10272 次 |
| 最近记录: |