对于为什么这不起作用感到困惑.提交表单时,我收到错误消息,这意味着我的重新验证失败.
@H_502_10@从我的形式:
<div class="g-recaptcha" data-sitekey="(site-key)"></div>
PHP:
if(isset($_POST['g-recaptcha-response'])){ $captcha=$_POST['g-recaptcha-response']; } $secretKey = "(secret-key)"; $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha); $responseKeys = json_decode($response,true); if(intval($responseKeys["success"]) === true) { echo '<h3>Thanks for your message!</h3>'; } else { echo '<h3>Error</h3>'; }