gpt4 book ai didi

ios - 验证 App 商店收据给出 DrmInvalidArgumentException

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:18:01 24 4
gpt4 key购买 nike

我正在关注此处的文档。

https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

我有一份来 self 的团队的收据数据,我正在尝试验证,他们收到错误代码 21002,这是格式错误的 JSON。看起来他们在 base64 数据上附加了额外的参数,所以我尝试删除这些参数并发送:

- (void)viewDidLoad {
[super viewDidLoad];

NSData *receipt; // Sent to the server by the device



// Create the JSON object that describes the request

NSError *error;

NSDictionary *requestContents = @{
@"receipt-data": @"<<$mybase64data>>", @"password" : @"<<$thepassword>>"};

NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents options:0 error:&error];



if (!requestData) { /* ... Handle error ... */ }



// Create a POST request with the receipt data.

NSURL *storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"];

NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];

[storeRequest setHTTPMethod:@"POST"];

[storeRequest setHTTPBody:requestData];



// Make a connection to the iTunes Store on a background queue.

NSOperationQueue *queue = [[NSOperationQueue alloc] init];

[NSURLConnection sendAsynchronousRequest:storeRequest queue:queue

completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

if (connectionError) {

/* ... Handle error ... */

NSLog(@"conerror %@", connectionError);
} else {

NSError *error;

NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];

NSLog(@"hello %@", jsonResponse);
NSLog(@"error %@", error);

if (!jsonResponse) {

}

}

}];



}

结果:

2017-03-03 22:45:47.454 receipttest[89851:352604] hello {
exception = "com.apple.jingle.mzfairplay.validators.DrmInvalidArgumentException";
status = 21002;
}
2017-03-03 22:45:47.455 receipttest[89851:352604] error (null)

最佳答案

需要牢记的一点:在本例中,数据直接从应用程序发送到 Apple,但您也可以从服务器执行此操作。当您测试您的服务器应用程序时,不要使用 NSLog() 来打印您的 base64 数据,NSLog 会截断数据。

关于ios - 验证 App 商店收据给出 DrmInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42591849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com