cURL Recaptcha not working PHP
curl, php
Solution
Because you're attempting to connect via SSL, you need to adjust your cURL options to handle it. A quick fix to get this to work is if you add `curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);`
Setting `CURLOPT_SSL_VERIFYPEER` to false will make it so that it accepts any certificate given to it rather than verifying them.
<?php
$data = array(
'secret' => "my-secret",
'response' => "my-response"
);
$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($verify, CURLOPT_POST, true);
curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($verify);
var_dump($response);
Problem
What I have: ``` $data = array( 'secret' => "my-app-secret", 'response' => "the-response" ); $verify = curl_init(); curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, CURLOPT_POST, true); curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($verify); var_dump($response); ``` What I got: `bool(false)` (which means the `curl_exec()` failed) What I expect: a JSON object response Please help. Thanks.