/** * 21000 APP store cannot read the JSON object you provided * 21002 receipt-data domain data is problematic * 21003 receipt cannot be verified * 21004 provided by shared secret does not match your account The shared secret * 21005 Receipt server is currently unavailable * 21006 receipt is legitimate, but the subscription has expired. When the server receives this status code, the receipt data is still decoded and sent together * 21007 receipt is a sandbox receipt, but is sent to the production System authentication Service * 21008 receipt is production receipt, But the verification service sent to the sandbox * * $receipt _data The payment voucher returned by Apple * $sandbox to 1 o'clock for the test address, and 0 for the trial address*/functionAcurl ($receipt _data,$sandbox=0){ //Small Ticket information $POSTFIELDS=Array("Receipt-data" =$receipt _data); $POSTFIELDS= Json_encode ($POSTFIELDS); //official purchase address sandbox purchase address $url _buy= "Https://buy.itunes.apple.com/verifyReceipt"; $url _sandbox= "Https://sandbox.itunes.apple.com/verifyReceipt"; $url=$sandbox?$url _sandbox:$url _buy; //Simple curl. $ch= Curl_init ($url); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields,$POSTFIELDS); $result= Curl_exec ($ch); Curl_close ($ch); $data= Json_decode ($result,true); //$data [' status ']==0 success//$data [' Receipt '] [' In_app '][0][' transaction_id '] apple order number//$data [' Receipt '] [' In_app ' ][0][' product_id ']; Commodity price return $data; }
PHP in Apple purchase order verification