问题描述
有人帮我找到使用 FedEx api 的费率服务吗?我有 3 个文件用于查找费率服务.
我已经从 https://www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/getstarted.html 在这里.当我运行 RateWebServiceClient.php 然后它显示一个错误:
交易返回错误.严重性:错误资料来源:教授代码:1000消息:身份验证失败
API 密钥、API 密码、仪表编号、帐号等所有凭据均正确
1.fedex-common.php5
2.RateWebServiceClient.php
3.RateService_v14.wsdl
require_once('fedex-common.php5');$newline = "
";//WSDL 不包含在示例代码中.//请在 $path_to_wsdl 变量中包含和引用.$path_to_wsdl = "RateService_v24.wsdl";ini_set("soap.wsdl_cache_enabled", "0");$client = new SoapClient($path_to_wsdl, array('trace' => 1));$request['WebAuthenticationDetail'] = array('用户凭据' =>大批('钥匙' =>getProperty('key'),'密码' =>getProperty('密码')));$request['ClientDetail'] = array('账号' =>getProperty('shipaccount'),'MeterNumber' =>getProperty('meter'));$request['TransactionDetail'] = array('CustomerTransactionId' =>' *** 使用 PHP 的速率请求 ***');$request['Version'] = array('ServiceId' =>'cr','主要' =>'24','中级' =>'0','小' =>'0');$request['ReturnTransitAndCommit'] = true;$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP';//有效值 REGULAR_PICKUP, REQUEST_COURIER, ...$request['RequestedShipment']['ShipTimestamp'] = date('c');$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY';//有效值 STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING';//有效值 FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...$request['RequestedShipment']['TotalInsuredValue']=array('金额'=>100,'货币'=>'美元');$request['RequestedShipment']['Shipper'] = addShipper();$request['RequestedShipment']['Recipient'] = addRecipient();$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();$request['RequestedShipment']['PackageCount'] = '1';$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
请试试这个代码.
';$xml .= '';$xml .= '<ns1:RateRequest>';$xml .='';$xml .= '';$xml .= '<ns1:Key></ns1:Key>';//在此处使用您的 Fedex 测试密钥$xml .= '<ns1:密码></ns1:密码>';////在此处使用您的 Fedex 测试密码$xml .= '</ns1:UserCredential>';$xml .= '</ns1:WebAuthenticationDetail>';$xml .='';$xml .= '<ns1:AccountNumber></ns1:AccountNumber>';$xml .= '<ns1:MeterNumber></ns1:MeterNumber>';$xml .= '</ns1:ClientDetail>';$xml .= '<ns1:TransactionDetail>';$xml .='';$xml .= '</ns1:TransactionDetail>';$xml .= '<ns1:Version>';$xml .= '<ns1:ServiceId>crs</ns1:ServiceId>';$xml .= '<ns1:Major>13</ns1:Major>';$xml .= '<ns1:Intermediate>0</ns1:Intermediate>';$xml .= '<ns1:Minor>0</ns1:Minor>';$xml .= '</ns1:Version>';$xml .= '<ns1:ReturnTransitAndCommit>true</ns1:ReturnTransitAndCommit>';$xml .='';$xml .= '<ns1:DropoffType>REGULAR_PICKUP</ns1:DropoffType>';$xml .= '<ns1:PackagingType>YOUR_PACKAGING</ns1:PackagingType>';$xml .= '';$xml .= '<ns1:Currency>USD</ns1:Currency>';$xml .= '</ns1:TotalInsuredValue>';$xml .= '<ns1:Shipper>';$xml .= '';$xml .= '<ns1:PersonName>发件人测试地址</ns1:PersonName>';$xml .= '<ns1:CompanyName>示例公司</ns1:CompanyName>';$xml .= '<ns1:PhoneNumber>800-5435-6789</ns1:PhoneNumber>';$xml .= '</ns1:Contact>';$xml .='';$xml .= '<ns1:StreetLines>1300 Basswood Road</ns1:StreetLines>';$xml .= '<ns1:City></ns1:City>';$xml .= '<ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>';$xml .= '<ns1:PostalCode>60173</ns1:PostalCode>';$xml .= '<ns1:CountryCode>US</ns1:CountryCode>';$xml .= '</ns1:Address>';$xml .= '</ns1:Shipper>';$xml .= '';$xml .= '';$xml .= '<ns1:PersonName>Harish</ns1:PersonName>';$xml .= '<ns1:CompanyName>Test</ns1:CompanyName>';$xml .= '<ns1:PhoneNumber>98656789130</ns1:PhoneNumber>';$xml .= '</ns1:Contact>';$xml .='';$xml .= '<ns1:StreetLines>奥尔巴尼华尔街32号</ns1:StreetLines>';$xml .= '<ns1:City>亚特兰大</ns1:City>';$xml .= '<ns1:StateOrProvinceCode>GA</ns1:StateOrProvinceCode>';$xml .= '<ns1:PostalCode>30318</ns1:PostalCode>';$xml .= '<ns1:CountryCode>US</ns1:CountryCode>';$xml .= '<ns1:Residential>true</ns1:Residential>';$xml .= '</ns1:Address>';$xml .= '</ns1:Recipient>';$xml .= '<ns1:ShippingChargesPayment>';$xml .= '<ns1:PaymentType>SENDER</ns1:PaymentType>';$xml .= '<ns1:Payor>';$xml .= '';$xml .= '<ns1:AccountNumber>510087100</ns1:AccountNumber>';$xml .= '</ns1:ResponsibleParty>';$xml .= '</ns1:Payor>';$xml .= '</ns1:ShippingChargesPayment>';$xml .= '<ns1:RateRequestTypes>LIST</ns1:RateRequestTypes>';$xml .= '<ns1:PackageCount>1</ns1:PackageCount>';$xml .= '<ns1:RequestedPackageLineItems>';$xml .= '<ns1:SequenceNumber>1</ns1:SequenceNumber>';$xml .= '<ns1:GroupPackageCount>1</ns1:GroupPackageCount>';$xml .= '<ns1:重量>';$xml .= '<ns1:Units>LB</ns1:Units>';$xml .= '<ns1:Value>45</ns1:Value>';$xml .= '</ns1:Weight>';$xml .= '<ns1:Dimensions>';$xml .= '<ns1:Length>12</ns1:Length>';$xml .= '<ns1:Width>9</ns1:Width>';$xml .= '<ns1:Height>8</ns1:Height>';$xml .= '<ns1:Units>IN</ns1:Units>';$xml .= '</ns1:Dimensions>';$xml .= '</ns1:RequestedPackageLineItems>';$xml .= '</ns1:RequestedShipment>';$xml .= '</ns1:RateRequest>';$xml .= '</SOAP-ENV:Body>';$xml .= '</SOAP-ENV:Envelope>';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://wsbeta.fedex.com:443/web-services');curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);curl_setopt($ch, CURLOPT_VERBOSE, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);$result_xml = curl_exec($ch);$result_xml = str_replace(array(':','-'), '', $result_xml);$result = @simplexml_load_string($result_xml);echo "";print_r($result);echo "</pre>";?>
Any one help me to find the rate services using FedEx api? I have 3 files for finding rate service.
I had Download all the three files from https://www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/getstarted.html here. When i run RateWebServiceClient.php then it shows a error:
The transaction returned an Error.Severity: ERRORSource: profCode: 1000Message: Authentication Failed
All credentials like API key, API password, Meter Number, Account Number are correct
1.fedex-common.php5
2.RateWebServiceClient.php
3.RateService_v14.wsdl
require_once('fedex-common.php5');
$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "RateService_v24.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$request['WebAuthenticationDetail'] = array(
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '24',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue']=array(
'Ammount'=>100,
'Currency'=>'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
Please try this code.
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v13">';
$xml .= '<SOAP-ENV:Body>';
$xml .= '<ns1:RateRequest>';
$xml .= '<ns1:WebAuthenticationDetail>';
$xml .= '<ns1:UserCredential>';
$xml .= '<ns1:Key></ns1:Key>'; // Use your Fedex Test Key Here
$xml .= '<ns1:Password></ns1:Password>'; //// Use your Fedex Test Password Here
$xml .= '</ns1:UserCredential>';
$xml .= '</ns1:WebAuthenticationDetail>';
$xml .= '<ns1:ClientDetail>';
$xml .= '<ns1:AccountNumber></ns1:AccountNumber>';
$xml .= '<ns1:MeterNumber></ns1:MeterNumber>';
$xml .= '</ns1:ClientDetail>';
$xml .= '<ns1:TransactionDetail>';
$xml .= '<ns1:CustomerTransactionId> *** Rate Request v13 using PHP ***</ns1:CustomerTransactionId>';
$xml .= '</ns1:TransactionDetail>';
$xml .= '<ns1:Version>';
$xml .= '<ns1:ServiceId>crs</ns1:ServiceId>';
$xml .= '<ns1:Major>13</ns1:Major>';
$xml .= '<ns1:Intermediate>0</ns1:Intermediate>';
$xml .= '<ns1:Minor>0</ns1:Minor>';
$xml .= '</ns1:Version>';
$xml .= '<ns1:ReturnTransitAndCommit>true</ns1:ReturnTransitAndCommit>';
$xml .= '<ns1:RequestedShipment>';
$xml .= '<ns1:DropoffType>REGULAR_PICKUP</ns1:DropoffType>';
$xml .= '<ns1:PackagingType>YOUR_PACKAGING</ns1:PackagingType>';
$xml .= '<ns1:TotalInsuredValue>';
$xml .= '<ns1:Currency>USD</ns1:Currency>';
$xml .= '</ns1:TotalInsuredValue>';
$xml .= '<ns1:Shipper>';
$xml .= '<ns1:Contact>';
$xml .= '<ns1:PersonName>Shipper Test Address</ns1:PersonName>';
$xml .= '<ns1:CompanyName>Sample Company</ns1:CompanyName>';
$xml .= '<ns1:PhoneNumber>800-5435-6789</ns1:PhoneNumber>';
$xml .= '</ns1:Contact>';
$xml .= '<ns1:Address>';
$xml .= '<ns1:StreetLines>1300 Basswood Road</ns1:StreetLines>';
$xml .= '<ns1:City></ns1:City>';
$xml .= '<ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>';
$xml .= '<ns1:PostalCode>60173</ns1:PostalCode>';
$xml .= '<ns1:CountryCode>US</ns1:CountryCode>';
$xml .= '</ns1:Address>';
$xml .= '</ns1:Shipper>';
$xml .= '<ns1:Recipient>';
$xml .= '<ns1:Contact>';
$xml .= '<ns1:PersonName>Harish</ns1:PersonName>';
$xml .= '<ns1:CompanyName>Test</ns1:CompanyName>';
$xml .= '<ns1:PhoneNumber>98656789130</ns1:PhoneNumber>';
$xml .= '</ns1:Contact>';
$xml .= '<ns1:Address>';
$xml .= '<ns1:StreetLines>32 wall street albany</ns1:StreetLines>';
$xml .= '<ns1:City>Atlanta</ns1:City>';
$xml .= '<ns1:StateOrProvinceCode>GA</ns1:StateOrProvinceCode>';
$xml .= '<ns1:PostalCode>30318</ns1:PostalCode>';
$xml .= '<ns1:CountryCode>US</ns1:CountryCode>';
$xml .= '<ns1:Residential>true</ns1:Residential>';
$xml .= '</ns1:Address>';
$xml .= '</ns1:Recipient>';
$xml .= '<ns1:ShippingChargesPayment>';
$xml .= '<ns1:PaymentType>SENDER</ns1:PaymentType>';
$xml .= '<ns1:Payor>';
$xml .= '<ns1:ResponsibleParty>';
$xml .= '<ns1:AccountNumber>510087100</ns1:AccountNumber>';
$xml .= '</ns1:ResponsibleParty>';
$xml .= '</ns1:Payor>';
$xml .= '</ns1:ShippingChargesPayment>';
$xml .= '<ns1:RateRequestTypes>LIST</ns1:RateRequestTypes>';
$xml .= '<ns1:PackageCount>1</ns1:PackageCount>';
$xml .= '<ns1:RequestedPackageLineItems>';
$xml .= '<ns1:SequenceNumber>1</ns1:SequenceNumber>';
$xml .= '<ns1:GroupPackageCount>1</ns1:GroupPackageCount>';
$xml .= '<ns1:Weight>';
$xml .= '<ns1:Units>LB</ns1:Units>';
$xml .= '<ns1:Value>45</ns1:Value>';
$xml .= '</ns1:Weight>';
$xml .= '<ns1:Dimensions>';
$xml .= '<ns1:Length>12</ns1:Length>';
$xml .= '<ns1:Width>9</ns1:Width>';
$xml .= '<ns1:Height>8</ns1:Height>';
$xml .= '<ns1:Units>IN</ns1:Units>';
$xml .= '</ns1:Dimensions>';
$xml .= '</ns1:RequestedPackageLineItems>';
$xml .= '</ns1:RequestedShipment>';
$xml .= '</ns1:RateRequest>';
$xml .= '</SOAP-ENV:Body>';
$xml .= '</SOAP-ENV:Envelope>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://wsbeta.fedex.com:443/web-services');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
$result_xml = str_replace(array(':','-'), '', $result_xml);
$result = @simplexml_load_string($result_xml);
echo "<pre>";
print_r($result);
echo "</pre>";
?>
这篇关于Fedex 是否提供折扣运费?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!