v2.5.2
Giriş yap

jsondan gelen datayı parçalamak

szrcmk
2,221 defa görüntülendi ve 2 kişi tarafından değerlendirildi

Merhabalar,

Aşağıdaki şekilde verilerimi alıyorum.

$Object = json_decode($Response->Data);
return $Object;

Tarayıcıya girdiğimde aşağıdaki gibi sonuç dönüyor, fakat ben buradan mesala sadece destination değerleri alıp veritabanına ekletmek istiyorum. Bu dönen sonuçta ki verileri parçalayıp istediğim verileri alamadım bir türlü

"Status": true,
"Data": [
{
"uniqueid": "1573421921.95355",
"values": [
{
"date": "11.11.2019 00:38:41",
"destination": "123456789",
"source": "123456789",
"duration": "00:00:00",
"direction": 3,
"recording": "",
"line": "123456789",
"directory": "\"123456789\" <123456789>"
}
]
},
...
szrcmk
1630 gün önce

Maalesef tayfun bu şekilde de alamadım. Almış olduğum hata şu şekilde;

SyntaxError: Unexpected token < in JSON at position 0
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/var/www/html/crm/Classes/Dashboard.class.php</b> on line <b>185</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/var/www/html/crm/Classes/Dashboard.class.php</b> on line <b>185</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/var/www/html/crm/Classes/Dashboard.class.php</b> on line <b>185</b><br />
{
"Status": true,
"Data": null
}

Kodum ise şu şekilde;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_URL,"https://siteismi.com/report");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $Response = new stdClass();
        $Response->Data = curl_exec ($ch);
        //curl_close ($ch);
        if (curl_errno($ch)) {
            echo "Hata :";
            print curl_error($ch);
        } else {
            curl_close($ch);
        }

        $Object = json_decode($Response->Data);
        return $Object->Data[0]->values[0]->destination;