script generate tracking number ups by post code example

Example 1: script generate tracking number ups by post

<?php
function upsTrack($trackingNumber) {
$data ="<?xml version=\"1.0\"?>
<AccessRequest xml:lang='en-US'>
  <AccessLicenseNumber>ACCESSNUMBER</AccessLicenseNumber>
  <UserId>USERNAME</UserId>
  <Password>PASSWORD</Password>
</AccessRequest>
<?xml version=\"1.0\"?>
<TrackRequest>
  <Request>
    <TransactionReference>
      <CustomerContext>
        <InternalKey>blah</InternalKey>
      </CustomerContext>
      <XpciVersion>1.0</XpciVersion>
    </TransactionReference>
    <RequestAction>Track</RequestAction>
  </Request>
  <TrackingNumber>$trackingNumber</TrackingNumber>
</TrackRequest>";
$ch = curl_init("https://www.ups.com/ups.app/xml/Track");

Example 2: script generate tracking number ups by post

$ch = curl_init("https://www.ups.com/ups.app/xml/Track");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$result=curl_exec ($ch);
// echo '<!-- '. $result. ' -->';
$data = strstr($result, '<?');

Tags:

Misc Example