4
我正在使用php爲iOS應用程序編寫服務器。如何使用php驗證Apple IAP收據?
我想通過訪問Apple的appstore服務器來檢查收據。
根據蘋果的幫助文件。我必須發送一個郵件請求到蘋果的服務器。
我怎樣才能做到這一點通過使用PHP,非常感謝!
任何人都可以舉個例子嗎?
我正在使用php爲iOS應用程序編寫服務器。如何使用php驗證Apple IAP收據?
我想通過訪問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.
?>
喜歡它!謝謝! – 2016-08-22 12:07:06
我會建議你使用捲曲並使用[http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase][1]來指導你 [1]:http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase – s1m0n 2012-07-09 16:54:18