473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to use fedex web service in php to calculate shipping fee

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:8pVQ6p5cHyQVuJJvrfosaBKqG
Developer Test Key: vfNOPSmeA69gJFdf
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.fedex.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('library/fedex-common.php5');

$newline = "<br />";
$path_to_wsdl = "wsdl/RateService_v3.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('UserCredential' =>
array('Key' => 'vfNOPSmeA69gJFdf', 'Password' => '8pVQ6p5cHyQVuJJvrfosaBKqG')); // Replace 'XXX' and 'YYY' with FedEx provided credentials
$request['ClientDetail'] = array('AccountNumber' => '510087682', 'MeterNumber' => '1239156');// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v3 using PHP ***');
$request['Version'] = array('ServiceId' => 'crs', 'Major' => '3', 'Intermediate' => '0', Minor => '0');
$request['Origin'] = array('StreetLines' => array('Sender Address Line 1'), // Origin details
'City' => 'Memphis',
'StateOrProvinceCode' => 'TN',
'PostalCode' => '38115',
'CountryCode' => 'US');
$request['Destination'] = array('StreetLines' => array('Destination Address Line 1'), // Destination details
'City' => 'Herndon',
'StateOrProvinceCode' => 'VA',
'PostalCode' => '20171',
'CountryCode' => 'US');
$request['Payment'] = array('PaymentType' => 'SENDER'); // valid codes RECIPIENT, SENDER and THIRD_PARTY
$request['DropoffType'] = 'REGULAR_PICKUP'; // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION
$request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['ShipDate'] = date('Y-m-d');
$request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST

$PassRateRequestPackageSummary = true;

if ($PassRateRequestPackageSummary)
{
// Passing multi piece shipment rate request (by setting PieceCount > 1)
$request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 20.0, 'Units' => 'LB'), // valid codes LB and KG
'TotalInsuredValue' => array('Amount' => 100, 'Currency' => 'USD'),
'PieceCount' => 2,
'SpecialServicesRequested' => array('SpecialServiceTypes' => 'NON_STANDARD_CONTAINER')); // valid codes HOLD_AT_LOCATION, ...
}
else
{
// Passing single piece shipment rate request
$request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage 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
'SpecialServicesRequested' => array('SpecialServiceTypes' => 'NON_STANDARD_CONTAINER'))); // valid codes HOLD_AT_LOCATION, ...
}

try
{
$response = $client ->getRate($request);

if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
{
printRequestResponse($client);
}
else
{
echo 'Error in processing transaction.'. $newline. $newline;
foreach ($response -> Notifications as $notification)
{
if(is_array($response -> Notifications))
{
echo $notification -> Severity;
echo ': ';
echo $notification -> Message . $newline;
}
else
{
echo $notification . $newline;
}
}
}

writeToLog($client); // Write to log file

} catch (SoapFault $exception) {
printFault($exception, $client);
}

?>
Jul 10 '08 #1
3 8459
dlite922
1,584 Expert 1GB
This is not a coding problem, but how to use an API.

Fedex should have the proper documentation you need. Consult them.
Jul 11 '08 #2
please please at least give me a name of that document, so i can study....
Jul 11 '08 #3
hsriat
1,654 Expert 1GB
please please at least give me a name of that document, so i can study....
Please consult FedEx, they might have some appropriate information for you.
We won't be able to guide you, unless someone here has already used that (probability is quite low).
Jul 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: grant | last post by:
hi folks: Does anyone know how to calculate the shipping rate on Fedex? There was a web module to handle the web query for rate at http://grd.fedex.com/cgi-bin/rrr2010.exe?func=Rate Currently...
8
by: Gabriel Cooper | last post by:
I've made UPS and FedEx shipping rate request modules in python using XML. Is there an interest in putting this on the web?
3
by: Ashish Kanoongo | last post by:
Hello I would like to calculate freight online for UPS and Fedex. However I have already calculate freight for ABF, Roadway and MyYellow, because they have provided sufficient documentation of...
2
by: Manmohan S. Sihra | last post by:
Hello, I need your help. I have to integrate FedEx or UPS's Rate Calculator with an eCommerce web site. I have a web site which offers some products for sale. The price of the products is being...
0
by: Bruce W.1 | last post by:
I'm developing a shopping cart for an ecommerce website. No big deal until I looked into calculating the postage and shipping of the product. By now I figured that UPS and The USPS would have a...
1
by: Terry Graham | last post by:
This is a total shot in the dark, but does anyone have any experience in setting up an ASP.NET project that only gets the shipping Rates from FedEx's live server? All I really want to accomplish...
13
by: Jennysaur | last post by:
Hi Everyone, I'm new to PHP, and completely new to this website. I'm having a problem getting the PHP FedEx Web services software to work, and it seems overly complicated. I just need a simple...
1
by: Adeel | last post by:
Hi, I want to show the shipping options offered by FedEx with there prices on my site. Does any one used it before or anyone has any idea about it. I am using asp.net 2.0. Please help me its...
2
by: sridharv86 | last post by:
Hi, I'm using FedEx for my shipment and use the FedEx rate calculator to find the shipping cost. When I send the request and get back the response, I always find that there is no discount applied...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.