我正在尝试使用 AFNetworking 向 API 发送一些参数。我已将我的应用程序代码缩减为:
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";
}
我一直收到“未设置团队”的回复。
当我转储 POST 时,我返回:
'array(0) {
}
(我假设一个空数组)?
我错过了什么?