我有一个用recrapcha发送电子邮件的表单,当我使用我在recaptcha faq中找到的测试站点密钥和密钥时一切正常 recaptcha faq
但是当我插入它时它不起作用,我也尝试重新创建键但问题仍然存在......任何建议? 这是我的PHP代码:
<?php
$response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=MY_SECRET_KEY&response='.$_POST['g-recaptcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR']);
$responseDecoded = json_decode($response);
if ( $responseDecoded->success == false ) {
echo 'Busted!';
exit();
}
else{
//here I insert the code for sending email
}
?>
答案 0 :(得分:1)
我认为问题出在这里。
secret=MY_SECRET_KEY
将MY_SECRET_KEY
替换为secret_key
中的实际file_get_contents()
。
答案 1 :(得分:0)
<强>解决强>
我注意到用于加载reCaptcha小部件的代码段不在表单内但在结束标记之后