I'm building a script to verify a transaction receipt with Apple's itunesconnect site (iphone dev) and I can't figure out where's the error in my code. I want to get the "status" value.
Please help me to find what am I doing wrong:
<?php
include("config.php");
$receipt = json_encode(array("receipt-data" => $_GET["receipt"]));
$response_json = do_post_request($url, $receipt);
$response = json_decode($response_json);
//Here's where I try to get the "status" key but doesn't work
echo $response['status'];
//echo $response->status;
function do_post_request($url, $data)
{
//initialize cURL
$ch = curl_init();
// set the target url
curl_setopt($ch, CURLOPT_URL,$url);
// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, 1);
// the receipt as parameter
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$result= curl_exec ($ch);
curl_close ($ch);
return $result;
}
?>
and the answer to the iPhone looks like:
{"receipt":{"item_id":"327931059", "original_transaction_id":"1000000000074412", "bvrs":"1.0", "product_id":"sandy_01", "purchase_date":"2009-09-29 16:12:46 Etc/GMT", "quantity":"1", "bid":"com.latin3g.chicasexy1", "original_purchase_date":"2009-09-29 16:12:46 Etc/GMT", "transaction_id":"1000000000074412"}, "status":0}
but only "status":0 matters for now - Thank's