3

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

5
  • where is curl_error() code in your question? also what is your url? Commented Jul 25, 2017 at 9:41
  • 1
    Also is your $request variable properly URL encoded, there is a function http_build_query() for that Commented Jul 25, 2017 at 9:42
  • i had used the curl_error but i removed it since it returns null Commented Jul 25, 2017 at 9:44
  • I also tried removing all post but still no luck Commented Jul 25, 2017 at 9:45
  • @Peter yes it is . I echoed it and checked Commented Jul 25, 2017 at 9:49

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@SaeeshTendulkar the point is, an update caused a problem with Apache that required it to be restarted, as soon as the update was applied. What was your resolution?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.