繁体   English   中英

DHL汇率计算

[英]DHL Rate calculation

在我的网站(基于php)中,我想实现DHL的费率计算器。 我想添加3个字段-1.Origin,2.Destination和3.Weight。 这3个值将被发送到DHL服务器,作为回报,我希望获得RATE。 我怎样才能做到这一点?

在另一部分中,我将在这三个字段中添加更多字段(地址,产品hts代码等)以获取RATE。 还可以怎么做?

以下是DHL费率计算器代码:您需要使用DHL站点ID和密码更改站点ID和密码。

<?php
$data = '<?xml version="1.0" encoding="UTF-8"?>
<p:DCTRequest xmlns:p="http://www.dhl.com" xmlns:p1="http://www.dhl.com/datatypes" xmlns:p2="http://www.dhl.com/DCTRequestdatatypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com DCT-req.xsd ">
  <GetQuote>
    <Request>
      <ServiceHeader>
        <MessageTime>'.date('c').'</MessageTime>
        <MessageReference>1234567890123456789012345678901</MessageReference>
        <SiteID>YOUR_DHL_SITE_ID</SiteID>
        <Password>YOUR_DHL_PASSWORD</Password>
      </ServiceHeader>
    </Request>
    <From>
        <CountryCode>GB</CountryCode>
        <Postalcode>WC1A</Postalcode>
    </From>
    <BkgDetails>
      <PaymentCountryCode>US</PaymentCountryCode>
      <Date>2011-06-06</Date>
      <ReadyTime>PT10H21M</ReadyTime>
            <ReadyTimeGMTOffset>+01:00</ReadyTimeGMTOffset>
            <DimensionUnit>CM</DimensionUnit>

            <WeightUnit>KG</WeightUnit>
            <Pieces><Piece>
                <PieceID>1</PieceID>
                <Height>20</Height>
                <Depth>20</Depth>
                <Width>20</Width>   
                <Weight>19</Weight>
            </Piece></Pieces>
            <IsDutiable>N</IsDutiable>
            <NetworkTypeCode>AL</NetworkTypeCode>
        </BkgDetails>
        <To>
            <CountryCode>US</CountryCode>
            <Postalcode>10101</Postalcode>
        </To>       
    </GetQuote>
</p:DCTRequest>';
$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, "https://xmlpitest-ea.dhl.com/XMLShippingServlet");
curl_setopt($tuCurl, CURLOPT_PORT , 443);
curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
curl_setopt($tuCurl, CURLOPT_HEADER, 0);
curl_setopt($tuCurl, CURLOPT_POST, 1);
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data);
curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($data)));

$tuData = curl_exec($tuCurl);

curl_close($tuCurl);
$xml = simplexml_load_string($tuData);
print "<pre>";
print_r($xml);
?>

有关更多参考,请单击以下链接:

http://xmlpitest-ea.dhl.com/serviceval/jsps/main/Main_menu.jsp

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM