// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://api.jde.ru/vD/cargos/status?user=00001&token=00004&ttn=0000006");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
echo '<pre>';
var_dump($output);
echo '</pre>';
function request($endpoint, $method, $data){
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
];
$result = curl_exec($ch);
if (empty($result)) {
return [
'status'=>false,
'error'=>curl_error($ch)
];
}
return [
'status'=>true,
'response'=>$result
];
}