I am trying to get status of a fededx tracking-id from the code sample which I have got from Fedex developer section, but unable to get required info of status of tracking id. I need help on this as I am novice to it. Please help how to get the response of status of tracking id of Fedex.
This file I'm executing => TrackWebServiceClient.php When executing this file I'm getting an error, which I have mentioned below: --------------------------- PHP_Common initialized Fault
Code:HTTP
String:Unable to parse URL
--------------------------
TrackWebServiceClient.php file code given below =>
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 6.0.0
require_once('fedex-common.php');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "TrackService_v16.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer
to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => '***
Track Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'trck',
'Major' => '16',
'Intermediate' => '0',
'Minor' => '0'
);
$request['SelectionDetails'] = array(
'PackageIdentifier' => array(
'Type' => 'TRACKING_NUMBER_OR_DOORTAG',
'Value' => '781193603730' //getProperty('trackingnumber') //
Replace 'XXX' with a valid tracking identifier
)
);
try {
if(setEndpoint('changeEndpoint')){
$newLocation = $client-
>__setLocation(setEndpoint('endpoint'));
}
$response = $client ->track($request);
if ($response -> HighestSeverity != 'FAILURE' && $response ->
HighestSeverity != 'ERROR'){
if($response->HighestSeverity != 'SUCCESS'){
echo '<table border="1">';
echo '<tr><th>Track Reply</th><th> </th></tr>';
trackDetails($response->Notifications, '');
echo '</table>';
}else{
if ($response->CompletedTrackDetails->HighestSeverity !=
'SUCCESS'){
echo '<table border="1">';
echo '<tr><th>Shipment Level Tracking Details</th>
<th> </th></tr>';
trackDetails($response->CompletedTrackDetails, '');
echo '</table>';
}else{
echo '<table border="1">';
echo '<tr><th>Package Level Tracking Details</th>
<th> </th></tr>';
trackDetails($response->CompletedTrackDetails-
>TrackDetails, '');
echo '</table>';
}
}
printSuccess($client, $response);
}else{
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
?>
I found a solution to it. Its now working. I missed out defining endpoint in fedex-common.php file, after I provided correct end point to it, it worked fine.