爲什麼USPS不適用此費率?我使用ratev4,我得到一個錯誤:USPS:API授權失敗
錯誤:
API Authorization failure. RateV4 is not a valid API name for this protocol.
UspsCom::DoAuth
這裏是我的代碼:
<?php
$devurl = "testing.shippingapis.com/ShippingAPITest.dll";
$puburl = "https://secure.shippingapis.com/ShippingAPITest.dll";
$service = "RateV4";
$userid = "690DEVBL1739";
$xml = rawurlencode('<RateV4Request USERID="xxxxx">
<Revision/>
<Package ID="1ST">
<Service>FIRST CLASS</Service>
<FirstClassMailType>LETTER</FirstClassMailType>
<ZipOrigination>44106</ZipOrigination>
<ZipDestination>20770</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0.0</Ounces>
<Container/>
<Size>REGULAR</Size>
<Machinable>true</Machinable>
</Package>
</RateV4Request>');
$request = $devurl . "?API=" . $service . "&xml=" . $xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($response);
echo "</pre>";
爲什麼你認爲RateV4應該是有效的? – stark 2012-04-02 01:55:49
[noPCommerce Forums](http://www.nopcommerce.com/boards/t/14719/estimate-shipping-configuration-upsusps-ratev4-is-not-a-valid-api.aspx)表明,測試服務尚未更新到RateV4;儘管這個帖子很古老。通過致電您的USPS客戶代表並要求澄清,您可能會獲得最佳服務。 – sarnold 2012-04-02 01:56:43
我已經嘗試過v3和v2,它們會產生相同的問題。 v2被禁用,因此它不再工作。 – 2012-04-02 02:06:44