1

我有一个 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] => 数组 () [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] => 数组 () [primary_ip] => 93.184.216.119 [ primary_port] => 80 [local_ip] => 79.174.170.11 [local_port] => 45182 [redirect_url] =>

那么是我的代码、我的服务器还是 API 的服务器在起作用?

4

1 回答 1

1

好的,我终于得到了我的答案,由我的网络主机建议。SSL 版本需要设置,PHP 不会自动确定:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);

感谢所有看过并提供帮助的人。

于 2013-09-13T09:54:58.013 回答