How to check getting Apple IAP using php?

I am using php to write a server for an iOS application.

I want to check the receipt by contacting the Apple appstore server.

According to Apple help document. I need to send a message to apple server.

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

How can I do this using php, thanks a lot!

Can someone give me an example?

+4
source share
1 answer
<?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. ?> 
+6
source

All Articles