cURL Recaptcha not working PHP
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);
Here's an alternative method to cURL I found if it helps anyone. Obviously input $secret and $response variables to pass it correctly. Sorry the question is asking for a cURL solution, but this is the quickest method I've seen so I thought it would add it anyway because I know it will help somebody out there. :)
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$response);
$response = json_decode($response, true);
if($response["success"] === true){
// actions if successful
}else{
// actions if failed
}