Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP return value from decoded object
    primarykey
    data
    text
    <p>Can someone please tell me where is the error in this code?, I use a mobile iphone application to call a php script tha will send information to apple. Apple then will return a JSON object containing several values in an associative array.</p> <p>I want to reach the 'status' value but every time I run the code in the phone, the php script sends me the complete apple's returned string. In the XCode debugger the received string looks like:</p> <blockquote> <p>[DEBUG]... responseString : {"receipt":{"item_id":"328348691", "original_transaction_id":"1000000000081203", "bvrs":"1.0", "product_id":"julia_01", "purchase_date":"2009-10-05 23:47:00 Etc/GMT", "quantity":"1", "bid":"com.latin3g.chicasexy1", "original_purchase_date":"2009-10-05 23:47:00 Etc/GMT", "transaction_id":"1000000000081203"}, "status":0}</p> </blockquote> <p>but the only piece I care in the string is the "status" value. I've already looked inside documentation but can't find the solution. I'm new in php but this getting too long. Here the script:</p> <pre><code>&lt;?php //The script takes arguments from phone's GET call $receipt = json_encode(array("receipt-data" =&gt; $_GET["receipt"])); //Apple's url $url = "https://sandbox.itunes.apple.com/verifyReceipt"; //USe cURL to create a post request //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,$receipt); $result = curl_exec ($ch); //Here the code "breaks" and return the complete string (i've tested that) //and apparently doesn't get to the json_decode function (i think something's wrong there, so code breaks here) curl_close ($ch); $response = json_decode($result); echo $response-&gt;{'status'}; ?&gt; </code></pre> <p>Even if I don't put any echo at the end, the script still returns a complete string (odd to me)</p> <p>Thank's in advance and apollogies if I insist again from another question</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload