I am trying to retrieve the POST data sent using AFSessionManager but cannot access the POST ($_POST['param']) data. I can, however, retrieve the GET ($_GET['param'])) when sending a GET command. Please help!
xcode:
NSString *baseURL = baseURLIn;
NSDictionary *parameters = inputKeys;
AFHTTPSessionManager *manager =[[AFHTTPSessionManager manager]initWithBaseURL:[NSURL URLWithString: baseURL]];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/xml"];
[manager POST:@"" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"re:%@, keys=%@", responseObject, parameters);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"h=%@",error);
}];
php:
if($_POST){
die(json_encode(array('e'=>$_POST['email'], 't'=>'emailAddress')));
}
The code listed above and documented at cocoadocs.org for AFNetworking are correct.
My error was in the URL string. my domain was being very specific about adding the "www" in front of the url.
If you are stuck, try this!