我正在尝试检索使用 AFSessionManager 发送的 POST 数据,但无法访问 POST ($_POST['param']) 数据。但是,我可以在发送 GET 命令时检索 GET ($_GET['param']))。请帮忙!
代码:
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')));
}