我一直在研究 Saia Carrier API,它给了我一些价值,尽管它们不是很吸引人。我想解析这些值并将它们放入变量中,以便可以在表格中整齐地显示它们。
这是代码:
<?php
$postdata = '<?xml version="1.0" encoding="utf-8"?>
<Create>
<UserID>XXX</UserID>
<Password>XXX</Password>
<TestMode>Y</TestMode>
<BillingTerms>Prepaid</BillingTerms>
<AccountNumber>XXX</AccountNumber>
<Application>Outbound</Application>
<OriginZipcode>44483</OriginZipcode>
<DestinationZipcode>90077</DestinationZipcode>
<Details>
<DetailItem>
<Weight>100</Weight>
<Class>85</Class>
</DetailItem>
</Details>
</Create>';
$url = "http://www.saiasecure.com/webservice/ratequote/xml.aspx";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-type: text/xml'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close ($ch);
$status = $info['http_code'];
echo $status;
echo '<pre>';
print_r($response);
?>