【发布时间】:2013-09-14 00:59:49
【问题描述】:
我有一个 PHP 脚本,它正在与第三方 API 通信,以使用 PHP CURL 和 SOAP 向他们发送订单信息。但现在它的反应绝对是零。不久前我们更换了服务器,但我的主机已经运行了一些测试以查看扩展程序是否正常工作。这是一些代码和调试:
$ch = curl_init($this->apiUrl);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$this->xmlRequest");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this->getCertificateXMLResponse = curl_exec($ch);
$aCURLinfo = curl_getInfo( $ch );
print_r( $aCURLinfo );
print_r 产生这个:
数组 ( [url] => https://www.theirdomain.com/theirdomain/Service/InsWebService.asmx [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [ redirect_count] => 0 [total_time] => 0.024002 [namelookup_time] => 0.001417 [connect_time] => 0.024017 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array () [primary_ip] => XXX.249.XXX.218 [ primary_port] => 443 [local_ip] => XX.174.XX.11 [local_port] => 44560 [redirect_url] => )
这是否意味着他们没有回应任何事情,或者这是我的问题?
我的虚拟主机设置了这个测试脚本来证明一个观点:
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
$aCURLinfo = curl_getInfo( $ch );
print_r( $aCURLinfo );
// close cURL resource, and free up system resources
curl_close($ch);
?>
然后弹出:
数组 ( [url] => http://www.example.com [content_type] => text/html [http_code] => 200 [header_size] => 322 [request_size] => 54 [filetime] => -1 [ssl_verify_result] = > 0 [redirect_count] => 0 [total_time] => 0.627453 [namelookup_time] => 0.429159 [connect_time] => 0.52812 [pretransfer_time] => 0.52816 [size_upload] => 0 [size_download] => 1270 [speed_download] => 2024 [speed_upload] => 0 [download_content_length] => 1270 [upload_content_length] => 0 [starttransfer_time] => 0.627415 [redirect_time] => 0 [certinfo] => Array () [primary_ip] => 93.184.216.119 [primary_port] = > 80 [local_ip] => 79.174.170.11 [local_port] => 45182 [redirect_url] => )
那么是我的代码、我的服务器还是 API 的服务器在起作用?
【问题讨论】:
-
HTTP-code 0 通常意味着您甚至没有拨打电话。您是否安装/编译了PHP-cURL?日志中有任何错误消息吗?
-
是的,我们这样做了——看看当我们运行代码访问 example.com 时发生了什么——我们得到:[http_code] => 200
-
使用详细模式进行调试:Php - Debugging Curl - 例如,这可能是不受支持的 SSL 模式。同时启用 PHP 错误日志到最高级别,并遵循 PHP 错误日志。
-
这是我的网络主机问题还是调试中的他们的服务器? pastebin.com/CEzEHGmG