您可以从受信任的服务器向 App Store 查询此信息。
沙盒环境的端点是https://sandbox.itunes.apple.com/verifyReceipt
对于生产来说,它是https://buy.itunes.apple.com/verifyReceipt
您需要将以下内容作为 JSON 有效负载发送:
receipt-data
如果您的服务器上没有它,可以通过调用NSBundle 的appStoreReceiptURL 方法来检索它。读取该文件的全部内容并将其发送到您的服务器。
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