我将此代码连接到 USPS API 并获得详细的响应长信息列表,然后是服务名称和费率。
我如何才能仅对由 (|) 分隔的服务名称和费率做出响应?
<?php
$devurl = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
$puburl = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
$service = "IntlRateV2";
$userid = "xxxxx";
$xml = rawurlencode('<IntlRateV2Request USERID="xxxxx">
<Package ID="1ST">
<Pounds>15</Pounds>
<Ounces>0</Ounces>
<MailType>Package</MailType>
<ValueOfContents>50</ValueOfContents>
<Country>Jordan</Country>
<Container>RECTANGULAR</Container>
<Size>LARGE</Size>
<Width>10</Width>
<Length>15</Length>
<Height>10</Height>
<Girth>0</Girth>
<CommercialFlag>N</CommercialFlag>
</Package>
</IntlRateV2Request>');
$request = $devurl . "?API=" . $service . "&xml=" . $xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($response);
echo "</pre>";