gpt4 book ai didi

php - DHL费率计算

转载 作者:行者123 更新时间:2023-12-02 07:50:35 24 4
gpt4 key购买 nike

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

在另一部分中,我将在这 3 个字段中添加更多字段(地址、产品 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

关于php - DHL费率计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4084977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com