Recaptcha v2 has stopped working across my sites, returning a 500 server error.
I've tried rejigging the code in case its an issue at my end but to no avail.
Can anyone see an issue with the below? All help appreciated
FORM
<form id="the_form" action="theprocess.php" method="post">
<input type="text" name="demoinput" id="demoinput">
<input type="submit" name="submit" value="Postit">
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="mysitekey"></div>
</form>
PROCESS
<?php
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
$secretKey = "mysecretkey";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>You are spammer !</h2>';
} else {
echo '<h2>Thanks for posting comment.</h2>';
}
?>