我有这个示例调用:
curl -i https://sandbox.espago.com/api/tokens -u publickey: -d "card[first_name]=Jan" -d "card[last_name]=Kowalski" -d "card[number]=4242424242424242" -d "card[verification_value]=123" -d "card[year]=2014" -d "card[month]=02"
我需要发出 POST (AFNetworking 1.3) 请求,我试过这样:
[self.client setAuthorizationHeaderWithUsername:self.publicKey password:@""];
NSDictionary *parameters = (@{
@"card[first_name]" : firstName,
@"card[last_name]" : lastName,
@"card[number]" : cardNumber,
@"card[verification_value]" : verificationCode,
@"card[year]" : @(year),
@"card[month]" : monthString,
});
NSString *path = [NSString stringWithFormat:@"%@/tokens", ZWEspagoURL];
[self.client postPath:path
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if(completion) completion(nil, error);
}];
但不幸的是,我得到了 401 或 422 HTTP 状态代码......
这个 curl 命令是 100% 好的,工作没有问题