我正在尝试使用Apple的沙盒服务器验证不可更新的订阅,但继续返回verify response: { "status":21002 }
,这意味着请求格式错误。这是我正在使用的相关代码:
NSString *receiptString = [[NSString alloc] initWithData:transactionReceipt
encoding:NSUTF8StringEncoding];
NSString *encodedString = [receiptString base64Encoding];
NSString *jsonString = [NSString stringWithFormat:@"{ 'receipt-data' : '%@' }", encodedString];
NSURL *verificationURL = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];
__block ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:verificationURL];
[request appendPostData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
[request setRequestMethod:@"POST"];
[request setCompletionBlock:^{
NSString *responseString = [request responseString];
NSLog(@"verify response: %@", responseString);
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"verify error: %@", [error description]);
}];
[request startAsynchronous];
显然问题是我通过ASIHTTPRequest库向Apple发送数据的方式。对此有任何见解表示赞赏。提前谢谢!