dimanche 5 avril 2015

JSON encoded list Type for POST call?

I am trying to do a POST call through an API but it doesn't really work.


When removing the items however it works fine.. The API requires items to be a JSON Encoded list.. What am I doing wrong?



$items = array(
"description" => $_GET['description'],
"sub_type" => $subtype_fd,
"amount" => floatval($_GET['amount']),
"calcium" => intval($_GET['calcium']),
"calories" => intval($_GET['calories']),
"carbohydrate" => floatval($_GET['carbohydrate']),
"cholesterol" => floatval($_GET['cholesterol']),
"fiber" => floatval($_GET['fiber']),
"protein" => floatval($_GET['protein']),
"saturated_fat" => floatval($_GET['saturated_fat']),
"unsaturated_fat" => floatval($_GET['unsaturated_fat']),
"sodium" => floatval($_GET['sodium']),
"sugar" => floatval($_GET['sugar']),
"caffeine" => floatval($_GET['caffeine'])
);

$json = json_encode($items);
var_dump($json);
$data = array('note' => $_GET['title'], 'sub_type' => $subtype_bld, 'items' => $json);




Aucun commentaire:

Enregistrer un commentaire