<?php
$track = $_GET['track'];
function get_web_page( $url )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => "Delivery Checker", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
/*
change url to your shippers tracking page substituting the tracking number
for ".$track." this will pass in the var from the order page in ISC
*/
$url = "
http://www.dhl.co.uk/publish/gb/en/eshi ... =fasttrack";
$content = get_web_page($url);
$content = $content['content'];
/* tried regex and failed using explode */
/* start is split point to chop out first part of page, end cuts of the last part mod to meet your needs */
$start ='Result summary';
$end = 'summaryFooter';
$matches = array();
$exploded = explode($start, $content,2);
$content = $exploded[1];
$exploded = explode($end, $content,2);
$content = $exploded[0];
/* we've got our text and some broken html here just extract text inside " " and put into array
Yes I know this is messy but it make this code easier to change to work with any shipper page */
$exploded = explode('"', $content);
/* uncomment the line below and run to list the contents of the array, you will need to view source of your status page to see the whole result. Find the array number containing your status text and change the echo line bellow substituting in your number.
Don't forget to comment it out again */
//print_r($exploded);
echo $exploded[15];
?>