hi:
can sone one tell me how to use fedex web service in php to calculate shipping fee? i already have fedex account and 4 keys used to test application
Test Password:8pVQ6p 5cHyQVuJJvrfosa BKqG
Developer Test Key: vfNOPSmeA69gJFd f
Test Account: 510087682
Test Meter: 1239156
and i also download source code:
Rate.php5
RateService_v3. xsd
fedex-common.php5
RateService_v3. wsdl
i did enter those 4 keys in rate.php5, and upload those files to my web host (at godaddy.com). but when i enter url Rate.php5, i gave me error like, can not connect to host...
fedex told me that they used xml to point to their server at https://gatewaybeta.fed ex.com:443/web-services
but i do not know how to pass 4 keys using xml and point to this service. help!!!!!!
//************ Rate.php5 *************** ********//
<?php
// Copyright 2008, FedEx Corporation. All rights reserved.
// Version 3.0.0
chdir('..');
require_once('l ibrary/fedex-common.php5');
$newline = "<br />";
$path_to_wsdl = "wsdl/RateService_v3. wsdl";
ini_set("soap.w sdl_cache_enabl ed", "0");
$client = new SoapClient($pat h_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticat ionDetail'] = array('UserCred ential' =>
array('Key' => 'vfNOPSmeA69gJF df', 'Password' => '8pVQ6p5cHyQVuJ JvrfosaBKqG')); // Replace 'XXX' and 'YYY' with FedEx provided credentials
$request['ClientDetail'] = array('AccountN umber' => '510087682', 'MeterNumber' => '1239156');// Replace 'XXX' with your account and meter number
$request['TransactionDet ail'] = array('Customer TransactionId' => ' *** Rate Request v3 using PHP ***');
$request['Version'] = array('ServiceI d' => 'crs', 'Major' => '3', 'Intermediate' => '0', Minor => '0');
$request['Origin'] = array('StreetLi nes' => array('Sender Address Line 1'), // Origin details
'City' => 'Memphis',
'StateOrProvinc eCode' => 'TN',
'PostalCode' => '38115',
'CountryCode' => 'US');
$request['Destination'] = array('StreetLi nes' => array('Destinat ion Address Line 1'), // Destination details
'City' => 'Herndon',
'StateOrProvinc eCode' => 'VA',
'PostalCode' => '20171',
'CountryCode' => 'US');
$request['Payment'] = array('PaymentT ype' => 'SENDER'); // valid codes RECIPIENT, SENDER and THIRD_PARTY
$request['DropoffType'] = 'REGULAR_PICKUP '; // valid codes BUSINESS_SERVIC E_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION
$request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNI GHT, PRIORITY_OVERNI GHT, FEDEX_GROUND, ...
$request['PackagingType'] = 'YOUR_PACKAGING '; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['ShipDate'] = date('Y-m-d');
$request['RateRequestTyp es'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST
$PassRateReques tPackageSummary = true;
if ($PassRateReque stPackageSummar y)
{
// Passing multi piece shipment rate request (by setting PieceCount > 1)
$request['RateRequestPac kageSummary'] = array('TotalWei ght' => array('Value' => 20.0, 'Units' => 'LB'), // valid codes LB and KG
'TotalInsuredVa lue' => array('Amount' => 100, 'Currency' => 'USD'),
'PieceCount' => 2,
'SpecialService sRequested' => array('SpecialS erviceTypes' => 'NON_STANDARD_C ONTAINER')); // valid codes HOLD_AT_LOCATIO N, ...
}
else
{
// Passing single piece shipment rate request
$request['PackageCount'] = 1; // currently only one occurrence of RequestedPackag e is supported
$request['Packages'] = array(0 => array('Weight' => array('Value' => 10.0, 'Units' => 'LB'), // valid code LB and KG
'InsuredValue' => array('Amount' => 100, 'Currency' => 'USD'),
'Dimensions' => array('Length' => '1', 'Width' => '1', 'Height' => '1', 'Units' => 'IN'), // valid code IN and CM
'SpecialService sRequested' => array('SpecialS erviceTypes' => 'NON_STANDARD_C ONTAINER'))); // valid codes HOLD_AT_LOCATIO N, ...
}
try
{
$response = $client ->getRate($reque st);
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
{
printRequestRes ponse($client);
}
else
{
echo 'Error in processing transaction.'. $newline. $newline;
foreach ($response -> Notifications as $notification)
{
if(is_array($re sponse -> Notifications))
{
echo $notification -> Severity;
echo ': ';
echo $notification -> Message . $newline;
}
else
{
echo $notification . $newline;
}
}
}
writeToLog($cli ent); // Write to log file
} catch (SoapFault $exception) {
printFault($exc eption, $client);
}
?>
can sone one tell me how to use fedex web service in php to calculate shipping fee? i already have fedex account and 4 keys used to test application
Test Password:8pVQ6p 5cHyQVuJJvrfosa BKqG
Developer Test Key: vfNOPSmeA69gJFd f
Test Account: 510087682
Test Meter: 1239156
and i also download source code:
Rate.php5
RateService_v3. xsd
fedex-common.php5
RateService_v3. wsdl
i did enter those 4 keys in rate.php5, and upload those files to my web host (at godaddy.com). but when i enter url Rate.php5, i gave me error like, can not connect to host...
fedex told me that they used xml to point to their server at https://gatewaybeta.fed ex.com:443/web-services
but i do not know how to pass 4 keys using xml and point to this service. help!!!!!!
//************ Rate.php5 *************** ********//
<?php
// Copyright 2008, FedEx Corporation. All rights reserved.
// Version 3.0.0
chdir('..');
require_once('l ibrary/fedex-common.php5');
$newline = "<br />";
$path_to_wsdl = "wsdl/RateService_v3. wsdl";
ini_set("soap.w sdl_cache_enabl ed", "0");
$client = new SoapClient($pat h_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticat ionDetail'] = array('UserCred ential' =>
array('Key' => 'vfNOPSmeA69gJF df', 'Password' => '8pVQ6p5cHyQVuJ JvrfosaBKqG')); // Replace 'XXX' and 'YYY' with FedEx provided credentials
$request['ClientDetail'] = array('AccountN umber' => '510087682', 'MeterNumber' => '1239156');// Replace 'XXX' with your account and meter number
$request['TransactionDet ail'] = array('Customer TransactionId' => ' *** Rate Request v3 using PHP ***');
$request['Version'] = array('ServiceI d' => 'crs', 'Major' => '3', 'Intermediate' => '0', Minor => '0');
$request['Origin'] = array('StreetLi nes' => array('Sender Address Line 1'), // Origin details
'City' => 'Memphis',
'StateOrProvinc eCode' => 'TN',
'PostalCode' => '38115',
'CountryCode' => 'US');
$request['Destination'] = array('StreetLi nes' => array('Destinat ion Address Line 1'), // Destination details
'City' => 'Herndon',
'StateOrProvinc eCode' => 'VA',
'PostalCode' => '20171',
'CountryCode' => 'US');
$request['Payment'] = array('PaymentT ype' => 'SENDER'); // valid codes RECIPIENT, SENDER and THIRD_PARTY
$request['DropoffType'] = 'REGULAR_PICKUP '; // valid codes BUSINESS_SERVIC E_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION
$request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNI GHT, PRIORITY_OVERNI GHT, FEDEX_GROUND, ...
$request['PackagingType'] = 'YOUR_PACKAGING '; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['ShipDate'] = date('Y-m-d');
$request['RateRequestTyp es'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST
$PassRateReques tPackageSummary = true;
if ($PassRateReque stPackageSummar y)
{
// Passing multi piece shipment rate request (by setting PieceCount > 1)
$request['RateRequestPac kageSummary'] = array('TotalWei ght' => array('Value' => 20.0, 'Units' => 'LB'), // valid codes LB and KG
'TotalInsuredVa lue' => array('Amount' => 100, 'Currency' => 'USD'),
'PieceCount' => 2,
'SpecialService sRequested' => array('SpecialS erviceTypes' => 'NON_STANDARD_C ONTAINER')); // valid codes HOLD_AT_LOCATIO N, ...
}
else
{
// Passing single piece shipment rate request
$request['PackageCount'] = 1; // currently only one occurrence of RequestedPackag e is supported
$request['Packages'] = array(0 => array('Weight' => array('Value' => 10.0, 'Units' => 'LB'), // valid code LB and KG
'InsuredValue' => array('Amount' => 100, 'Currency' => 'USD'),
'Dimensions' => array('Length' => '1', 'Width' => '1', 'Height' => '1', 'Units' => 'IN'), // valid code IN and CM
'SpecialService sRequested' => array('SpecialS erviceTypes' => 'NON_STANDARD_C ONTAINER'))); // valid codes HOLD_AT_LOCATIO N, ...
}
try
{
$response = $client ->getRate($reque st);
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
{
printRequestRes ponse($client);
}
else
{
echo 'Error in processing transaction.'. $newline. $newline;
foreach ($response -> Notifications as $notification)
{
if(is_array($re sponse -> Notifications))
{
echo $notification -> Severity;
echo ': ';
echo $notification -> Message . $newline;
}
else
{
echo $notification . $newline;
}
}
}
writeToLog($cli ent); // Write to log file
} catch (SoapFault $exception) {
printFault($exc eption, $client);
}
?>
Comment