7

我正在使用 php 为 iOS 应用程序编写服务器。

我想通过访问 Apple 的应用商店服务器来检查收据。

根据苹果的帮助文档。我必须向苹果的服务器发送一个发布请求。

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingStoreReceipts.html#//apple_ref/doc/uid/TP40008267-CH104-SW1

我怎么能用php做到这一点,非常感谢!

谁能给我一个例子?

4

1 回答 1

15
<?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.

?>
于 2013-01-05T13:10:20.093 回答