I want to send orders from an ecommerce to an API with order details.
Must sent to specified URL + the GUID in header, I use it but got no result.
I can save null in the fields with that value. Please help, I'm new with PHP.
The PHP is:
<?php
$url = 'https://url.ro:447/api/WebShop/SetOrderInvoiceAndPayment';
$data = array(
"Cif" => null,
"Cnp" => null,
"Email" => "catalin.duca@mail.ro",
"FirstName" => "Catalin",
"LastName" => "Duca",
"CollectionId" => "1",
"DocumentDate" => "2020-12-22 11:57:43",
"DocumentDueDate" => null,
"OrderDeliveryDate" => null,
"OrderExplanation" => "test",
"OrderNo" => "11111",
"PartnerId" => null,
"Payments" => array (),
"Products" => array (
"Bbd" => null,
"Lot" => null,
"ProductId" => "49102",
"Qpp" => null,
"Quantity" => "1",
"RetailPrice" => "18.69",
"ServiceName" => null,
"SubgestId" => null
)
);
$postdata = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Guid: demoguid'
));
$result = curl_exec($ch);
curl_close($ch);
print_r ($result);
?>