dongpan2788 2019-01-17 23:32
浏览 82

PHP UPS跟踪无响应

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

  • 写回答

1条回答 默认 最新

  • dragon87836215 2019-01-18 20:49
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法