CURL Request problem CURL Request problem curl curl

CURL Request problem


In fact, you can just disable peer HOST verification. In some PHP/cURL version, just disabling PEER is not enough:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

From the docs:

CURLOPT_SSL_VERIFYHOST: 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided. In production environments the value of this option should be kept at 2 (default value).


Change: $ch = curl_init( 'https://sandbox.paypal.com/cgi-bin/webscr' );
To: $ch = curl_init( 'https://www.sandbox.paypal.com/cgi-bin/webscr' );

Reason: the certificate for www.sandbox.paypal.com is not valid for sandbox.paypal.com.
Make the same change in your form's 'action' as well, by the way.


You need to tell cURL not to verify the SSL certificate. This can be done by setting a cURL option:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

More information here:

http://php.net/manual/en/function.curl-setopt.php