Hi guys i have problem with google reCaptcha.
Here is my php code:
$secret = 'SECRET_KEY';
$response = $_POST['g-recaptcha-respone'];
$remoteip = $_SERVER['REMOTE_ADDR'];
$url = "https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$response&remoteip=$remoteip";
$result_json = file_get_contents($url);
$resulting = json_decode($result_json, true);
print_r($resulting);
if($resulting['success']) {
//Success
}
input of print_r is: Array ( [success] => [error-codes] => Array ( [0] => missing-input-response ) )
How to solve this problem?
Thanks for answers
im not able to comment so im going to answer here. i copied my code which works perfectly. and btw, $_POST['g-recaptcha-respone'], are you sure your inputs name is 'g-recaptcha-respone'?
In my case I needed to add two extra parameters (
'', '&'
) in this call:Please note :
g-recaptcha-respone
!=g-recaptcha-response
Google reCatcha API you might need to specify additional parameters to the
file_get_contents
function call, setting the context options specifically for SSL (If site has SSL).At least on ubuntu - If site has SSL
and your cafile and path will be