I have store javascript object in my database in this form
{"paymethod_id":1,"business_id":76,"delivery_type":"1","driver_tip":0,"delivery_zone_id":6569,"delivery_datetime":null,"location":{"lat":18.7675049,"lng":-103.1445221},"deliveryOptionmodal":{"id":2,"value":"Esperar en la entrada","$$hashKey":"object:589"},"delivery_cost_new":20,"products":"[{\"id\":48732,\"code\":\"FiIMyb\",\"quantity\":1,\"options\":[],\"ingredients\":[]}]","customer_id":129731,"customer":"{\"id\":129731,\"name\":\"bil\",\"middle_name\":null,\"lastname\":\"ar\",\"second_lastname\":null,\"photo\":null,\"email\":\"bilal1212@gmail.com\",\"cellphone\":\"0213123132131\",\"address\":\"Coalcom\u00e1n, Michoac\u00e1n, Mexico\",\"location\":\"{\\\"lat\\\":18.7675049,\\\"lng\\\":-103.1445221}\",\"internal_number\":null,\"address_notes\":\"sss\",\"zipcode\":null,\"map_data\":{\"library\":\"google\",\"place_id\":\"ChIJz6WGrUw-MIQR_jYIoFZ-RPM\"},\"tag\":\"home\"}"}
Now i am trying to send this data with api after converting it into array but that is giving me bad request error
Here is my method to send an api request in laravel php file
$data = json_decode($order->data, true);
$data['products'] = json_decode($data['products'], true);
$data['customer'] = json_decode($data['customer'], true);
if (date('Y-m-d H:i:s') >= date('Y-m-d H:i:s', strtotime($order->schedule_date))) {
$url = 'https://apiv4.ordering.co/v400/en/demo/orders';
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => array(
"X-APP-X: web",
"Content-Type: application/json",
),
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire