How to get JSON response? If PHP print some JSON whole request failed, if PHP does not print anything then response succeed. How to work with AFHTTPRequestOperation ?
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo":@"barr"};
UIImage *image = myImage.image;
[manager POST:@"http://local/index.php"
parameters:parameters
constructingBodyWithBlock:^(id<AFMultipartFormData> formData){
[formData appendPartWithFileData:UIImageJPEGRepresentation(image, 0.7)
name:@"file"
fileName:@"photo.jpg"
mimeType:@"image/jpeg"];
}
success:^(AFHTTPRequestOperation *operation, id responseObject){
NSLog(@"Success: %@", responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"Error %@", operation.responseString);
}];