我正尝试使用AFNetworking将一些参数发送到API。我减少了我的应用程序代码:无法读取POST参数
NSDictionary *params = @{@"team":@"WashingtonNationals"};
[_client postPath:@"updateTeamAlert"
parameters:params
success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Request Successful, response '%@'", responseStr);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
}];
在服务器上,我使用了下面的PHP调试:
if (isset($_POST["team"])) {
echo "team set ok";
}
else {
echo "team not set";
}
我始终接受“队没有设置”响应。
当我vardump我返回POST:
'array(0) {
}
(空数组我假定)?
我错过了什么?
而不是使用'isset'以这种方式调试只是'var_dump($ _ POST)'并看看它踢出了什么 – Vector
谢谢 - 我更新了问题。 –