Reputation: 703
The code i've used is
$request = 'sales='.$_slots['sales']['value'].'&duration='.$_slots['duration']['value'];
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, $url );
curl_setopt( $ch,CURLOPT_POST, 2 );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, $request);
$result = curl_exec($ch );
$response = explode(chr(10),$result);
$data = implode('', $response);
$error = curl_error($ch)
curl_close( $ch );
The curl_error
also returns null
so I have no way to track why its not working. The $url
is defined above and is a valid url.I also tried without sending any post but still it does not work.
Any advice would be appreciated.Thanks
Upvotes: 3
Views: 2248
Reputation: 1910
In my case, curl was only showing this behavior on https URLs, whether CURLOPT_SSL_VERIFYHOST
and CURLOPT_SSL_VERIFYPEER
are set to false for testing, or not, just as you have here.
I had recently run a yum update
which updated Name Service Switch, which was the only change to the server I could think of. I updated via yum on another server, and that server started to show the same failure in curl.
Restarting the Apache service resolved the issue. Https URLs worked in curl after this restart.
I did find examples of curl/ssl/nss errors occurring in the past, but in my case never saw an error message.
This isn't a very satisfying resolution because I don't feel like I have a full picture of why this failure occurred, so I will continue to investigate and add an update if I find something more.
Upvotes: 1