$tracking_number
]
]);
$ch = curl_init($import_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Track123-Api-Secret: $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $import_data);
curl_exec($ch);
curl_close($ch);
// STEP 2: Query tracking
$query_url = "https://api.track123.com/gateway/open-api/tk/v2/track/query";
$query_data = json_encode([
"trackNos" => [$tracking_number]
]);
$ch = curl_init($query_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Track123-Api-Secret: $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_data);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
?>
Track Your Shipment
window.location.href='/tracking/".$_GET['tn']."';"; } // Show result if($tracking_number) { echo "Tracking Number: ".$tracking_number."
"; $data = track123_api($tracking_number); if(!empty($data['data'])) { $shipment = $data['data'][0]; echo "Status: ".$shipment['status']."
"; echo "Carrier: ".$shipment['courierName']."
"; // Timeline if(!empty($shipment['events'])) { echo "Tracking History
"; echo "- ";
foreach($shipment['events'] as $event) {
echo "
- ".$event['time']." - ".$event['status']." (".$event['location'].") "; } echo "
No tracking data found.
"; } } ?>