Business::FedEx::RateRequest uses a simple XML/POST instead of the slower and more complex Soap based method to obtain available rates between two zip codes for a given package weight and size. At the time of this writing FedEx evidently encourages the use of Soap to get available rates and provides source code examples for Java, PHP, C# but no Perl. FedEx doesn't provide non-Soap XML examples that I could find. Took me a while to develop the XML request but it returns results faster than the PHP Soap method.
The XML returned is voluminous, over 30k bytes to return a few rates, but is smaller than the comparable Soap results.
SYNOPSIS
use Business::FedEx::RateRequest;
use Data::Dumper;
# Get your account/meter/key/password numbers from Fedex
my %rate_args;
$rate_args{'account'} = '_your_account_number_';
$rate_args{'meter'} = '_your_meter_number_';
$rate_args{'key'} = '_your_key_';
$rate_args{'password'} = '_your_password_';
$rate_args{'uri'} = 'https://gatewaybeta.fedex.com:443/xml/rate';
my $Rate = new Business::FedEx::RateRequest(%rate_args);
my %ship_args;
$ship_args{'src_zip'} = '83835';
$ship_args{'dst_zip'} = '55411';
$ship_args{'weight'} = 5;
# Optional args
$ship_args{'dst_residential'} = 'true'; # defualt is commercial
$ship_args{'insured_value'} = 50;
my $rtn = $Rate->get_rates(%ship_args);
if ( $rtn ) { print Dumper $rtn }
else { print $Rate->err_msg() }
Should return something like
$VAR1 = [
{
'ship_cost' => '112.93',
'ServiceType' => 'FIRST_OVERNIGHT'
},
{
'ship_cost' => '48.91',
'ServiceType' => 'PRIORITY_OVERNIGHT'
},
{
'ship_cost' => '75.04',
'ServiceType' => 'STANDARD_OVERNIGHT'
},
{
'ship_cost' => '42.84',
'ServiceType' => 'FEDEX_2_DAY'
},
{
'ship_cost' => '28.81',
'ServiceType' => 'FEDEX_EXPRESS_SAVER'
},
{
'ship_cost' => '7.74',
'ServiceType' => 'FEDEX_GROUND'
}
];
Product's homepage
Requirements:
· Perl