Hi i have a an api file for fetching orders coming in my magento2 store , this is the code below which is successfully fetching my order number 66 from database , **`
i wants to know how can i fetch only last order placed in my list ?
`** so that i can get all upcoming latest orders.
<?php
$adminUrl='http://host.pk/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "user11", "password" => "pass11");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token= json_decode($token);
//Use above token into header
$headers = array("Authorization: Bearer $token");
$requestUrl='http://host.pk/index.php/rest/V1/orders/66';
$ch = curl_init();
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$result= json_decode($result);
echo "<pre>";
print_r($result);
echo "</pre>";
?>