[英]How to verify Apple IAP receipt using php?
我正在使用php為iOS應用程序編寫服務器。
我想通過訪問Apple的appstore服務器來查看收據。
根據蘋果的幫助文件。 我必須向蘋果的服務器發送一個帖子請求。
我怎么能用php做到這一點,非常感謝!
任何人都可以舉個例子嗎?
<?php
$applesharedsecret = "applesecretfromyourdevaccount";
$receiptbytes = "......applereceipt.......";
$appleurl = "https://buy.itunes.apple.com/verifyReceipt"; // for production
// use https://sandbox.itunes.apple.com/verifyReceipt for testing with sandbox receipt
$request = json_encode(array("receipt-data" => $receiptbytes,"password"=>$applesharedsecret));
$ch = curl_init($appleurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$jsonresult = curl_exec($ch);
curl_close($ch);
var_dump($jsonresult); // see the details of the receipt.
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.