New Google reCAPTCHA keeps failing to verify with localhost
It's possible that allow_url_fopen = Off
in your php.ini
, preventing file_get_contents
from opening URLs.
You could just use cURL for this, something like this:
$fields = array( 'secret' => "MySecretKey", 'response' => $captcha, 'remoteip' => $_SERVER['REMOTE_ADDR'] ); $ch = curl_init("https://www.google.com/recaptcha/api/siteverify"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); $response = json_decode(curl_exec($ch)); curl_close($ch);