[英]How get FEDEX_ONE_RATE API using php
如何使用 php 获得 FEDEX_ONE_RATE API
我试图通过JeremyDunn/php-fedex-api-wrapper但不使用标准费率很好,当我尝试“FEDEX_ONE_RATE”时没有任何改变。
试试 1
$rateRequest->ShipmentSpecialServicesRequested->SpecialServiceTypes = 'FEDEX_ONE_RATE';
试试 2
$rateRequest->VariableOptions = array(SimpleType\ServiceOptionType::_FEDEX_ONE_RATE);
上述两种方法的请求都附加了参数,但结果没有改变。
任何人帮助我。
如果不查看您的确切请求很难说,但假设您正在提交RateRequest
,那么您需要:
RateRequest.VariableOptions
FEDEX_ONE_RATE
为ServiceOptionType
。FEDEX_SMALL_BOX
、 FEDEX_MEDIUM_BOX
、 FEDEX_LARGE_BOX
、 FEDEX_EXTRA_LARGE_BOX
、 FEDEX_PAK
、 FEDEX_TUBE
、 FEDEX_ENVELOPE
)。有关所有详细信息,请参阅FedEx 文档。
例如,使用以下请求:
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>...</Key>
<Password>...</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>...</AccountNumber>
<MeterNumber>...</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<VariableOptions>FEDEX_ONE_RATE</VariableOptions>
<RequestedShipment>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<Shipper>
<Address>
<StateOrProvinceCode>TN</StateOrProvinceCode>
<PostalCode>38017</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Shipper>
<Recipient>
<Address>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>90028</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>...</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>10.00</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
相应的响应将是(为了突出重要部分,我省略了很多细节):
<RateReply>
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>crs</Source><Code>0</Code>
<Message>Request was successfully processed. </Message>
<LocalizedMessage>Request was successfully processed. </LocalizedMessage>
</Notifications>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<RateReplyDetails>
<ServiceType>FIRST_OVERNIGHT</ServiceType>
...
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<DestinationAirportId>BUR</DestinationAirportId>
<ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
<RatedShipmentDetails>
...
</RatedShipmentDetails>
</RateReplyDetails>
<RateReplyDetails>
<ServiceType>FIRST_OVERNIGHT</ServiceType>
...
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<AppliedOptions>FEDEX_ONE_RATE</AppliedOptions>
<DestinationAirportId>BUR</DestinationAirportId>
<ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
<RatedShipmentDetails>
<ShipmentRateDetail>
<SpecialRatingApplied>FEDEX_ONE_RATE</SpecialRatingApplied>
...
</ShipmentRateDetail>
...
</RatedShipmentDetails>
</RateReplyDetails>
</RateReply>
即,对于每个ServiceType
(例如FIRST_OVERNIGHT
),将返回两组费率:一组没有应用FEDEX_ONE_RATE
(如 RateReplyDetails 中的AppliedOptions
和SpecialRatingApplied
元素的存在突出RateReplyDetails
)。
最后我得到了解决
这是 postman(SOAP 请求)的工作代码
$url = 'https://ws.fedex.com:443/web-services/rate';
//沙盒$url = 'https://wsbeta.fedex.com:443/web-services/rate';
// 居住
$xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v28"> <SOAP-ENV:Body>
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>.....</Key>
<Password>....</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>....</AccountNumber>
<MeterNumber>....</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<VariableOptions>FEDEX_ONE_RATE</VariableOptions>
<RequestedShipment>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<Shipper>
<Address>
<StateOrProvinceCode>TN</StateOrProvinceCode>
<PostalCode>38017</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Shipper>
<Recipient>
<Address>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>90028</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>.....</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>10.00</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.