您可以从受信任的服务器上查询App Store以获取此信息。
沙盒环境的端点是
https://sandbox.itunes.apple.com/verifyReceipt
至于制作,它是
https://buy.itunes.apple.com/verifyReceipt
您需要将以下内容作为JSON有效负载发送:
receipt-data
如果服务器上没有,可以通过调用
appStoreReceiptURL
方法
NSBundle
.读取该文件的全部内容并将其发送到服务器。
Password
(仅适用于自动续费订阅,这将是你应用的共享秘密)
exclude-old-transactions
仅用于包含自动续费或不续费订阅的iOS7样式的应用程序收据。如果值为true,则响应仅包括任何订阅的最新续订事务。
然后它将返回一个包含收据的有效载荷
status
以及其他一些附加信息。
Check this article at Apple
编辑
使用cURL调用App Store端点(如上链接)。这里是一个粗略的例子,您需要根据您的特定环境对其进行修改,并填写所需的变量。
$service_url = [one of the two above];
$curl = curl_init($service_url);
$curl_post_data = array(
'receipt-data' => $receiptData,
'password' => $password, //Only required for certain types of subscription
'exclude-old-transactions' => $excludeoldtransactions //Depends on your use case, check Apple link
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
$info = curl_getinfo($curl);
curl_close($curl);
die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($curl_response);
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
die('error occured: ' . $decoded->response->errormessage);
}
echo 'response ok!';
var_dump($decoded->response);
http://php.net/manual/en/book.curl.php