PHP code example of 200mph / aramex
1. Go to this page and download the library: Download 200mph/aramex 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/ */
200mph / aramex example snippets
use thm\Aramex\AramexClient;
use thm\Aramex\ServiceBuilder\Service\TrackingService\TrackingService;
use thm\Aramex\AramexException;
try {
$client = new AramexClient();
$client->setAccountCountryCode('GB')
->setAccountEntity('ABC')
->setAccountNumber(123456)
->setAccountPin(1234)
->setUserName('[email protected]')
->setPassword('aramex_password_here');
$ts = new TrackingService($client);
$ts->setShipments( array('Ship111111111', 'Ship22222222', 'Ship3333333') )
->sendRequest();
// return tracking collection
$tracks = $ts->getResponse()->getTracks();
var_dump($tracks);
foreach($tracks as $track) {
var_dump($track->getWaybillNumber());
}
// get whole object
var_dump($ts->getResponse());
// catch errors
var_dump($ts->getResponse()->hasErrors());
var_dump($ts->getResponse()->getNotifications());
} catch (AramexException $ae) {
var_dump($ae->getMessage());
}