#!/usr/bin/php <?php require_once "RoyalMailTracker.php"; if ($_SERVER['argc'] != 2) { echo "Usage: RoyalMailTrack.php TRACKING_NUMBER"; echo "\n"; exit(1); } try { $rm = new RoyalMail(); $tracker = $rm->Track($_SERVER['argv'][1]); // First print the service type echo "Service: " . $tracker['rmService'] . "\n\n"; // First print the delivery decision: if ($tracker['deliveryDecision'] == "True") { echo "This item has been delivered."; } else { echo "This item has not been delivered."; } echo "\n\n"; // Then print the status updates: echo "** Status updates for this item **\n\n"; foreach ($tracker['statusLines'] as $statusUpdate) { echo $statusUpdate['date'] . " " . $statusUpdate['time'] . " - " . $statusUpdate['report'] . " - " . $statusUpdate['location']; echo "\n"; } } catch (Exception $e) { echo $e->getMessage(); } echo "\n";
<?php require_once "RoyalMailTracker.php"; try { $rm = new RoyalMail(); $tracker = $rm->Track($_GET['t']); echo json_encode($tracker); } catch (Exception $e) { $err = array('error' => $e->getMessage()); echo json_encode($err); } echo "\n";