afnetworking-2

AFNetworking XML Request Issue

雨燕双飞 提交于 2019-12-10 16:27:27
问题 I'm using AFNetworking-2 with JSON response and it was working fine and now I have to convert it to XML instead of using JSON because the server response is in XML. After I've searched I reached with this code but it is not working. With Charles I found the request is wrong "Fail to parse data (org.xml.sax.SAXParseException: Content not allowed is prolog)" Please where would be my issue? My code: NSString *urlString = BaseURLString; NSURL *url = [[NSURL alloc] initWithString:urlString];

AFJSONParameterEncoding in AFNetworking 2.x.x

点点圈 提交于 2019-12-10 15:04:42
问题 I am implementing following paypal REST API: curl -v https://api.sandbox.paypal.com/v1/vault/credit-card \ -H 'Content-Type:application/json' \ -H 'Authorization: Bearer {accessToken}' \ -d '{ "payer_id":"user12345", "type":"visa", "number":"4417119669820331", "expire_month":"11", "expire_year":"2018", "first_name":"Joe", "last_name":"Shopper" }' I have successfully implement this api in AFNetworking 1.3.3 with following Code. Where PPWebService is subclass of AFHTTPClient [[PPWebService

AFNetworking include headers

北城余情 提交于 2019-12-10 14:55:08
问题 I'm trying to convert from ASIHttpRequest to AFNetworking but I seem to be having a "Use of undeclared identifier AFURLSessionManager" error on the following line in my class. AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; I have included the following on my header: #import "AFNetworking.h" #import "AFURLSessionManager.h" It must be something really obvious, but having a bad brain fart right now. 回答1: The behavior is simply explained

Error when uploading photo with AFNetworking

本小妞迷上赌 提交于 2019-12-10 11:57:42
问题 I am uploading a photo using AFNetworking and I am getting the infamous "request body stream exhausted" error. This is my code: ( _manager is a AFHTTPRequestOperationManager ) NSData *imageData = UIImageJPEGRepresentation(image, 1.0); AFHTTPRequestOperation *operation = [_manager POST:address parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:imageData name:@"file" fileName:@"image.jpg" mimeType:@"image/jpeg"]; } success:^

NSURLSessionDownloadTask resumes automatically all task while in background

吃可爱长大的小学妹 提交于 2019-12-10 10:55:01
问题 I have requirement to download files in serial order. Currently I am able to do that while app is in foreground. Following is the logic I have used. Create all tasks for downloading. Resume one at a time and as the current finishes resume the next one from URLSession:task:didCompleteWithError: . This logic is working while app is in foreground but once app started to run in background(By crashing) and we again run the app before download finishes all the tasks state has been changed to resume

Uploading selected image from photo library using AFNetworking and PHP

丶灬走出姿态 提交于 2019-12-10 10:46:25
问题 I am trying to upload an image which selected from photo library using AFNetworking but I am little confused. Some code samples are using image data directly for upload and some are using file path. I want to use AFNetworking sample code here: NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSURL *URL = [NSURL URLWithString:@"http:/

POST Request with AFNetworking 2.0 not working, but working in HTTP Request tester

浪子不回头ぞ 提交于 2019-12-09 13:38:05
问题 I've just started using the new AFNetworking 2.0 API having used the previous versions for a while now. I'm trying to do a bog standard http POST request , but sadly I'm not doing too well. This is my current code: AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{@"username" : self.usernameField.text, @"password" : self.passwordField.text}; [operationManager POST:@"https:URL GOES HERE" parameters:parameters success:^

AFNetworking 2.0 multipart request body blank

ε祈祈猫儿з 提交于 2019-12-09 06:52:30
问题 Similar to this issue. Using AFNetworking 2.0.3 and trying to upload an image using AFHTTPSessionManager's POST + constructingBodyWithBlock. For reasons unknown, it seems as though the HTTP post body is always blank when the request is made to the server. I subclass AFHTTPSessionManager below (hence the usage of [self POST ...] . I've tried constructing the request two ways. Method 1 : I just tried to pass params and then add only the image data should it exist. - (void) createNewAccount:

How to check whether host(server) is available or not in iOS with AFNetworking

萝らか妹 提交于 2019-12-09 04:39:28
I am using AFNetworking in my App for communicating with server. How can i check whether my host(server) is available or not, i should check this before i am sending a request to server. Using AFNetworking 2.0 that provide method like below you can check instead of using Reachability class. - (void)viewDidLoad { [super viewDidLoad]; [[AFNetworkReachabilityManager sharedManager] startMonitoring]; } After set start-monitoring in to viewDidLoad you can check any where in to class using Bellow Method. if ([[AFNetworkReachabilityManager sharedManager] isReachable]) { NSLog(@"IS REACHABILE"); } else

is it possible to install AFNetworking 2.0 with Restkit

核能气质少年 提交于 2019-12-08 15:01:18
问题 I got an news app which fetches news online in XML format in stores it locally in the sqlite dbase.. which is perfect case for restkit. However, I would like to also fetch xml data manually sometimes (ie and not want to store it in the dbase).. in other words i would like to request it directly with AFNetworking. I like how in AFNetworking 2.0 it does the parsing of xml automatically, and so I want to use that feature. However, Restkit 2.0 is linked to AFNetworking 1.3.. and so If I add this