Reputation: 809
I had a PHP script which was communicating with a third party API to send them order information using PHP CURL and SOAP. But now there is absolutely zero response from it. We changed servers a while back but my host has ran some tests to see the extensions are all working. Here's some code and debug:
$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 );
The print_r produces this:
Array ( [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] => )
Does that not suggest they are not responding with anything or is it a problem my end?
My web host set up this test script to prove a point:
<?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);
?>
And out pops:
Array ( [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] => )
So is it my code, my server, or the API's server acting up?
Upvotes: 1
Views: 481
Reputation: 809
OK I finally got my answer, suggested by my web host. SSL version needed setting, not automatically determining by PHP:
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
Thank you to everyone who looked and helped.
Upvotes: 1