Çözümlenen nesneden PHP dönüş değeri

1 Cevap php

Bu kodda hata nerede Birisi bana söyleyebilir misiniz?, Ben elma bilgi gönderecek bir php komut dosyası tha aramak için bir mobil iphone uygulamasını kullanabilirsiniz. Apple daha sonra bir ilişkisel dizi birkaç değerlerini içeren bir JSON nesnesi dönecektir.

Ben 'statü' değerine ulaşmak istiyorum ama telefonda kod çalıştırmak her zaman, php script bana tam elma döndü dize gönderir. XCode ayıklayıcısında alınan dize gibi görünüyor:

[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}

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:

<?php
//The script takes arguments from phone's GET call
$receipt = json_encode(array("receipt-data" => $_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->{'status'};


?>

Ben sonunda herhangi bir yankı koymak bile, komut hala (bana garip) tam bir dize döndürür

Ben başka bir soru tekrar ısrar önceden ve apollogies de bulunuyor ederiz