1. Go to this page and download the library: Download sauladam/shipment-tracker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sauladam / shipment-tracker example snippets
use Sauladam\ShipmentTracker\ShipmentTracker;
$dhlTracker = ShipmentTracker::get('DHL');
/* track with the standard settings */
$track = $dhlTracker->track('00340434127681930812');
// scrapes from http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc=00340434127681930812
/* override the standard language */
$track = $dhlTracker->track('00340434127681930812', 'en');
// scrapes from http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=en&idc=00340434127681930812
/* pass additional params to the URL (or override the default ones) */
$track = $dhlTracker->track('00340434127681930812', 'en', ['zip' => '12345']);
// scrapes from http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=en&idc=00340434127681930812&zip=12345
if($track->delivered())
{
echo "Delivered to " . $track->getRecipient();
}
else
{
echo "Not delivered yet, The current status is " . $track->currentStatus();
}
$latestEvent = $track->latestEvent();
echo "The parcel was last seen in " . $latestEvent->getLocation() . " on " . $latestEvent->getDate()->format('Y-m-d');
echo "What they did: " . $latestEvent->description();
echo "The status was " . $latestEvent->getStatus();