我去了DHL online shipment tracking 并看到表单提交。
我想将它包含在我的网站上。 我怎么能用PHP做到这一点?
答案 0 :(得分:3)
以下链接可让您了解使用DHL API进行DHL跟踪的信息
http://xmlpitest-ea.dhl.com/serviceval/jsps/main/Main_menu.jsp
<?php
$data = '<?xml version="1.0" encoding="UTF-8"?>
<req:KnownTrackingRequest xmlns:req="http://www.dhl.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dhl.com
TrackingRequestKnown.xsd">
<Request>
<ServiceHeader>
<MessageTime>'.date('c').'</MessageTime>
<MessageReference>1234567890123456789012345678</MessageReference>
<SiteID>YOUR_SITE_ID</SiteID>
<Password>YOUR_PASSWORD</Password>
</ServiceHeader>
</Request>
<LanguageCode>en</LanguageCode>
<AWBNumber>7070000000</AWBNumber>
<LevelOfDetails>ALL_CHECK_POINTS</LevelOfDetails>
</req:KnownTrackingRequest>';
$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);
$simple = $tuData;
$xml = simplexml_load_string($tuData);
print"<pre>";
print_r($xml);
?>