Skip to content

Instantly share code, notes, and snippets.

@pushandplay
Created October 27, 2014 08:46
Show Gist options
  • Save pushandplay/f2c3784996a3595b1b68 to your computer and use it in GitHub Desktop.
Save pushandplay/f2c3784996a3595b1b68 to your computer and use it in GitHub Desktop.
<?php
$applesharedsecret = "XXXXXXXXXXX";
$receiptbytes = $_POST['receiptbytes'];
//$appleurl = "https://buy.itunes.apple.com/verifyReceipt"; // for production
$appleurl = "https://sandbox.itunes.apple.com/verifyReceipt"; // for testing
$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);
echo($jsonresult);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment