- Joined
- Nov 19, 2020
- Posts
- 2,683
- Reaction
- 4,446
- Points
- 1,546
How to be able to display where is the parcel's exact location using php.
$tracking_number = '1234567890'; // replace with your tracking number
$api_key = 'your_api_key'; // replace with your API key
$url = 'https://api.shippingcompany.com/tracking?tracking_number='.$tracking_number.'&api_key='.$api_key;
// create cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// parse JSON response
$data = json_decode($response, true);
// get current location
$location = $data['tracking_info'][0]['location'];
// display location
echo 'Current location: '.$location;