I want to use AFNetworking 2.0 to get the XML data of RSS in this site : http://www.ifanr.com/feed but I get this :
Error: Error Domain=AFNetworkingErrorDomain Code=-1016
"Request failed: unacceptable content-type: application/rss+xml" UserInfo=0x8c21d50
{NSErrorFailingURLKey=http://www.ifanr.com/feed, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x8c14c90> { URL: http://www.ifanr.com/feed } { status code: 200, headers {
"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/xml; charset=UTF-8";
Date = "Thu, 07 Nov 2013 08:07:29 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
"Last-Modified" = "Thu, 07 Nov 2013 07:34:23 GMT";
Pragma = "no-cache";
Server = "nginx/1.5.6";
"Set-Cookie" = "ifanr_sidebar_showcase_index=3, PHPSESSID=i58cv75l1djp5gdrajn28qo8e5; path=/, liveblog-client-id=78878135; path=/";
"Transfer-Encoding" = Identity;
"X-Join-Us" = "http://jobboard.ifanr.com/, tifan <at> ifanr.com";
"X-Pingback" = "http://www.ifanr.com/xmlrpc.php";
"X-UA-Compatible" = "IE=Edge,chrome=1";
"X-XSS-Protection" = "1; mode=block";
} }, NSLocalizedDescription=Request failed: unacceptable content-type: application/rss+xml}
And here is my code :
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager setResponseSerializer:[AFXMLParserResponseSerializer new]];
[manager GET:@"http://www.ifanr.com/feed" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Data: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
something wrong?
I have sloved this question by myself. simply add the following statements:
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/rss+xml"]
[manager setResponseSerializer:[AFXMLParserResponseSerializer new]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With