php - PHP UPS 跟踪无响应
问题描述
这是我对 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 中提供它,都没有打印或回显。我不应该看到什么吗?
favicon 有一个 404,但这没什么。这应该工作!至少不应该抛出异常吗?某物!
跟踪号来自 UPS 文档第 7 页“跟踪 Web 服务开发人员指南”
提前致谢
解决方案
与所有评论一样,您可以看到该问题与未使用最新的 openssl 有关,后者具有 UPS 和其他人寻求具有安全 cURL 发布和响应的 tsl 1.2。
以防万一其他人经历此过程,以下是我为使我的 mac os 10.10 合规工作而采取的步骤。
首先,我从 openssl.org 下载了最新的 openssl 并安装了——你可以通过谷歌搜索比我给出的更好的说明,但基本上要确保你的 brew 是最新的并使用它来安装。
这将在 CLI(命令行界面)上获得最新的 openssl,但它不适用于 apache/php Web 浏览器。我通过创建一个 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
感谢所有评论的人。一件事导致另一件事达到这一点,我感谢大家。
推荐阅读
- android - 属性布局 ScrollFlag 未找到
- c - 从内核模块写入文件
- r - 在 Ubuntu 20.04 上安装 R 的最佳方式是什么?
- ios - 如何在swift中使用第一个后来的大写本地化字符串?
- julia - Julia 如何从 SymPy 求解集中获取系数
- flutter - 在 dart 中操作 StackTrace
- wpf - Giving my ContextMenu style treatment not working
- python - 从纸空间梯度笔记本连接谷歌驱动器 - ERR_CONNECTION_REFUSED
- docker - 如何更改默认 Docker 存储库以在 Dockerfile 中使用
- c# - c# 比较特定的像素颜色和图片颜色