【发布时间】:2017-07-13 13:15:15
【问题描述】:
我已经在我的 html 表单上实现了重新捕获代码,没有问题。
我在标头中有 java 脚本参考。我得到了 g-recaptcha-response 的结果,但是当我尝试验证它时,我没有得到任何结果,我什么也得不到,没有错误,什么也没有。我检查了我的网站并且密钥是正确的。我还将 $resp 放在 $status 中,以查看经过验证的响应来自 google,它始终显示为空。我无法弄清楚我做错了什么。
<div class="g-recaptcha" data-sitekey="MY.SITE.KEY"></div>
<br/>
<button name="submit" type="submit">Submit Registration Form</button>
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response']))
//your site secret key
$secret = 'MY.SECRET.KEY';
//get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
$resp = json_decode($verifyResponse);
if ($resp->success==false)
{
$proceed = false;
$status .= "You entered the ReCaptcha field incorrectly!".$resp."<br />";
}
【问题讨论】: