Sunday 15 June 2014

php - Cannot Decode JSON API response -



php - Cannot Decode JSON API response -

i have built api shipping quote system. feed values , rate quotes back. works fine cannot decode json response. null response , i'm not sure whats up. according validaters json correct.

so encode php array on 1 side , want parse on other side using browser , php. however, null response.

here json. allow me know if need more.

{"carrier":"r&l carriers","charge":"99.13","service_days":"wednesday oct. 22, 2014"}

i want decode can parse it. if there way parse please allow me know.

also, searched sof , similar issues people having here didn't help me.

this code utilize generate json.

<?php //include ('mysql_connect.php'); $result = mysql_query('select * quote user_id = "'.$user_id.'" order netcharge asc limit 1'); if (!$result) { die('could not query:' . mysql_error()); } if (!$result) echo mysql_error(); $api_data = array(); $api_count = '0'; while ($row = mysql_fetch_array($result, mysqli_assoc)) { $api_data[carrier] = $row['carrier']; $api_data[charge] = $row['netcharge']; $api_data[service_days] = $row['servicedays']; $api_count++; } $api_data = json_encode($api_data); print_r($api_data); ?>

this i'm using grab json data:

<?php $input = file_get_contents('api_request.php?dest_zip=66101&weight=200&class=50&ltl_shipment=x&residential_delivery=x'); echo $input; $obj = json_decode($input); var_dump($obj); ?>

have tried following

$array = json_decode($data, true);

php json parsing

No comments:

Post a Comment