【问题标题】:Do not getting the price of Priority Mail Express in USPS shipping不要在 USPS 运输中获得 Priority Mail Express 的价格
【发布时间】:2015-04-27 01:54:12
【问题描述】:

我需要获取标准邮件、优先邮件和优先快递邮件的费率。使用下面的代码,我得到的是优先邮件和标准邮件的费率,而不是优先快递邮件的费率。

当我在服务栏中写优先快递邮件时,出现如下错误(优先邮件快递)

“请求的邮件服务不适用于指定的请求属性。”

我使用的代码是这样的:

{

$url = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
        $ch = curl_init();
        // set the target url
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        // parameters to post
        curl_setopt($ch, CURLOPT_POST, 1);
        $data = "API=RateV4&XML=<RateV4Request USERID=\"$userName\"><Package ID=\"1ST\"><Service>All</Service><ZipOrigination>$orig_zip</ZipOrigination><ZipDestination>$dest_zip</ZipDestination><Pounds>$weight</Pounds><Ounces>0</Ounces><Container/><Size>REGULAR</Size><Machinable>FALSE</Machinable></Package>
        </RateV4Request>";

        // send the POST values to USPS
        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
        $result=curl_exec ($ch);
        $data = strstr($result, '<?');
         //echo '<!-- '. $data. ' -->'; // Uncomment to show XML in comments
        $xml_parser = xml_parser_create();
        xml_parse_into_struct($xml_parser, $data, $vals, $index);
        xml_parser_free($xml_parser);
        $params = array();
        $level = array();
        foreach ($vals as $xml_elem) {
        if ($xml_elem['type'] == 'open') {
        if (array_key_exists('attributes',$xml_elem)) {
        list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
        } else {
        $level[$xml_elem['level']] = $xml_elem['tag'];
        }
        }
        if ($xml_elem['type'] == 'complete') {
        $start_level = 1;
        $php_stmt = '$params';
        while($start_level < $xml_elem['level']) {
        $php_stmt .= '[$level['.$start_level.']]';
        $start_level++;
        }
        $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
        eval($php_stmt);
        }
        }
        curl_close($ch);
        //print_r($data);exit;
        echo '<pre>'; print_r($params); echo'</pre>'; // Uncomment to see the full array
        //echo $params['RATEV4RESPONSE']['1ST'][$servicecode]['RATE'];exit;

}

【问题讨论】:

    标签: shipping usps fedex


    【解决方案1】:

    Priority Mail Express 不适用于所有类型的货件,在这种情况下可能会受到限制。鉴于您的请求适用于其他邮件类,这很可能是运输问题,而不是技术问题。如果您可以分享您发送的特定参数,将会有所帮助。

    如果您想了解 USPS 运费,您可以使用简单的 UI 或 API 在https://goshippo.com免费检索运费。

    【讨论】:

    • 感谢回复用户名是 282CYBER5970
    • 始发地邮编:20505,目的地邮编:01010,重量:12lbs
    • 包装尺寸和重量是多少?另外,为什么将 MACHINABLE 设置为 false?大多数包装和信封都是可加工的。
    • 好的,我会让可加工成真的,我没有输入包装尺寸是不是也必须给出尺寸?
    • 包装尺寸不是必需的,但重量是。
    猜你喜欢
    • 1970-01-01
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 2017-10-18
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 2017-12-03
    相关资源
    最近更新 更多