0

This is my first crack at UPS tracking and I am getting absolutely nothing. I see 200 in the network tab, but that is from my server, serving up the page.

Do you see anything wrong with the following code:

    <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// UPS SHIP ORDER TRACKING
$xmlRequest1='<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>my access key</AccessLicenseNumber>
<UserId>my user id</UserId>
<Password>my password</Password>
</AccessRequest>
<?xml version="1.0"?>
<TrackRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Your Test Case Summary
Description</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<RequestAction>Track</RequestAction>
<RequestOption>activity</RequestOption>
</Request>
<TrackingNumber>1Z12345E0205271688</TrackingNumber>
</TrackRequest>';

  try
  {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://wwwcie.ups.com/ups.app/xml/Track");
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3600);

    echo $xmlResponse = curl_exec ($ch); // TRACKING RESPONSE
  }
  catch(Exception $ex)
  {
    print_r("Exception: " . $ex);
  }

Whether I serve it in http or if go command line php post_track_ups_2.php, there is nothing being printed or echoing. Shouldn't I see something?

There is a 404 for the favicon, but that's nothing. This should work! Shouldn't there be an exception thrown at least? Something!

The tracking number is from UPS documentation page 7 "Tracking Web Service Developer Guide"

Thanks in advance

kronus
  • 902
  • 2
  • 16
  • 34
  • 1
    White Screen of Death == `error_reporting` and/or `display_errors` needs to be turned on/up. – Sammitch Jan 17 '19 at 23:39
  • Your php/curl is fine to establish the communicate, are you viewing the source of your output as plain text (Ctrl+U)? Obviously I can't confirm since I'd need a license key. – Scuzzy Jan 17 '19 at 23:42
  • @Sammitch thank you for replying. I have added error_reporting(E_ALL); ini_set('display_errors', 1); and still nothing – kronus Jan 17 '19 at 23:44
  • @Scuzzy thank you for replying. I do not know what you mean by (Ctrl+U). Do you mean make sure the file is saved as plain text? – kronus Jan 17 '19 at 23:46
  • I don't think your curl request failing will cause an exception. It will just return false, and echoing that won't print anything. You can check for curl errors after exec to see what the problem is. – Don't Panic Jan 17 '19 at 23:50
  • Is it expecting two XML documents in one request? – Don't Panic Jan 17 '19 at 23:53
  • @kronus in your code, can you try adding `var_dump(curl_error($ch),curl_errno($ch));` after you've performed `curl_exec()` – Scuzzy Jan 18 '19 at 00:08
  • Why do you switch off `CURLOPT_SSL_VERIFYHOST`? – Dharman Jan 18 '19 at 00:14
  • @Dharman thanks for replying, I switched it off because I am not posting from SSL server - just my local dev environment. I also read that turning this off is one step in trouble shooting cURL. It is less likely to have an error when turned off, so to say – kronus Jan 18 '19 at 01:00
  • @Don'tPanic thank you for replying. I am using what I read. I could try to combine the two xmls, but I do not understand why there is nothing being returned. Not even an authentication error – kronus Jan 18 '19 at 01:02
  • @Scuzzy, thanks for the suggestion. It returned the following - string 'error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version' (length=79)int 35 - I haven't looked up the error yet, but does this mean the server will not accept a post from my dev server, which does not have SSL? – kronus Jan 18 '19 at 01:04
  • You're using a VERY old OpenSSL version and you absolutely need to upgrade. In fact, upgrade everything in a 100m radius of that box, as there's probably more gremlins hiding in the area. – Sammitch Jan 18 '19 at 01:18
  • @Sammitch, thank you for replying. Yes, I used brew update, followed by brew upgrade openssl, which moved me up to openssl 1.02q, but doesn't seem to have made a difference. I am still receiving the same error – kronus Jan 18 '19 at 01:23
  • I was able to create a ls to the 1.02q version of openssl, which allowed me to run from command line resulted in the following response - Your Test Case SummaryDescription1.00ResponseStatusDescription>FailureError>ErrorSeverity>Hard151018Invalid tracking number – kronus Jan 18 '19 at 03:12
  • Looks like you're all set then. – Scuzzy Jan 18 '19 at 03:14
  • @Scuzzy I was unable to have phpinfo() show the latest openssl, as I have on CLI. Do you know what I need to do to update in apache or for apache to see the latest version? Since I will be posting to php file from Angular, I need it work in apache – kronus Jan 18 '19 at 03:15
  • for phpinfo in CLI... https://stackoverflow.com/questions/7190093/phpinfo-an-easy-way-for-seeing-it – Scuzzy Jan 18 '19 at 03:39
  • @Scuzzy, sorry that I was not clear earlier, but my phpinfo lists an old version of openssl. My CLI has the latest and that is why my php is working from command line. As I said earlier, I need to post from my Angular app to the php file, which means that my php in the browser needs to have access to the latest openssl. With phpinfo it is showing OpenSSL/0.9.8zd but my CLI is 1.02q. How do I get the web server to use the openssl 1.02q version? – kronus Jan 18 '19 at 04:54

1 Answers1

0

As with all the comments, you can see that the issue had to do with not using the latest openssl, which has tsl 1.2 that UPS and others look for to have secure cURL post & respond.

Just in case anyone else goes through this, here are the steps that I took to make my mac os 10.10 working in compliance.

First, I downloaded the latest openssl from openssl.org and installed - you can google for better instructions than I could give, but basically make sure your brew is up to date and use it to install.

That will get the latest openssl on CLI (command line interface), but it will not work with apache/php web browser. I discovered this by making a phpInfo() page and, to my shock, it still read 0.9.8zf

After a lot of reading, this is what I did:

cd into the openssl directory that you expanded after download

Your paths maybe different than mine, so adjust accordingly:

cd /Users/<home directory>/Downloads/openssl-1.0.2q
./Configure darwin64-x86_64-cc -fPIC shared --prefix=/PREFIX/openssl --openssldir=/PREFIX/openssl
make
make test
make install

brew install php --with-apache --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-openssl --without-snmp

set path - /usr/local/Cellar/php56/5.6.9/bin/php in httpd-ssl.conf
also export /usr/local/Cellar/php56/5.6.9/bin/php in ~/.bash_profile
source ~/.bash_profile

insert the following line into httpd.conf

LoadModule php5_module /usr/local/Cellar/php56/5.6.9/libexec/apache2/libphp5.so
sudo apachectl restart

Thanks to all who commented. One thing lead to another to get to this point and I thank you all.

kronus
  • 902
  • 2
  • 16
  • 34