【问题标题】:PHP UPS tracking no responsePHP UPS 跟踪无响应
【发布时间】:2019-06-12 05:39:33
【问题描述】:

这是我第一次尝试 UPS 跟踪,但我一无所获。我在网络选项卡中看到 200,但那是来自我的服务器,正在提供页面。

您是否发现以下代码有任何问题:

    <?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);
  }

无论我是在 http 中还是在命令行 php post_track_ups_2.php 中提供它,都没有任何内容被打印或回显。我不应该看到什么吗?

网站图标有一个 404,但这没什么。这应该工作!至少不应该抛出异常吗?东西!

跟踪号来自 UPS 文档第 7 页“跟踪 Web 服务开发人员指南”

提前致谢

【问题讨论】:

  • 白屏死机 == error_reporting 和/或 display_errors 需要打开/打开。
  • 您的 php/curl 可以很好地建立通信,您是否以纯文本 (Ctrl+U) 形式查看输出源?显然我无法确认,因为我需要许可证密钥。
  • @Sammitch 感谢您的回复。我添加了 error_reporting(E_ALL); ini_set('display_errors', 1);还是什么都没有
  • @Scuzzy 感谢您的回复。我不知道您所说的(Ctrl + U)是什么意思。你的意思是确保文件保存为纯文本?
  • 我认为您的 curl 请求失败不会导致异常。它只会返回 false,并且回显不会打印任何内容。你可以在exec之后检查curl错误,看看是什么问题。

标签: php ups


【解决方案1】:

与所有 cmets 一样,您可以看到该问题与未使用最新的 openssl 有关,它具有 UPS 和其他人寻求安全 cURL 发布和响应的 tsl 1.2。

以防万一其他人遇到这种情况,以下是我为使我的 mac os 10.10 合规工作而采取的步骤。

首先,我从 openssl.org 下载了最新的 openssl 并进行了安装 - 您可以在 Google 上找到比我提供的更好的说明,但基本上要确保您的 brew 是最新的并使用它来安装。

这将在 CLI(命令行界面)上获得最新的 openssl,但它不适用于 apache/php 网络浏览器。我通过创建一个 phpInfo() 页面发现了这一点,令我震惊的是,它仍然显示为 0.9.8zf

经过大量阅读,这就是我所做的:

cd into the openssl directory that you expanded after download

您的路径可能与我的不同,因此请相应调整:

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

将以下行插入 httpd.conf

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

感谢所有评论的人。一件事导致另一件事达到这一点,我感谢大家。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-23
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    相关资源
    最近更新 更多