How to test HTTPS CURL in development server?

HTTPS is secure HTTP communication based on SSL protocol (HTTP over SSL). Generally all sensitive info (like passwords, financial details, etc.) are sent over this transport. Common example: your gmail login is done through HTTPS channel and different payment gateway.
So here in this deal –

$postfields = array('field1'=>'value1', 'field2'=>'value2');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://foo.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);

CURLOPT_SSL_VERIFYHOST is off. This allows you to test the CURL in your dev server without having HTTPS. PHP/Curl will handle the http request.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *