Google Recaptcha - GetResponse不返回JSON

Mig*_*ade 3 html javascript jquery json recaptcha

我一直在为我们的网站实现一个新的登录页面,其中一个要求是对表单中的两个元素进行重新访问(一个用于注册,另一个用于获取用户名/密码提醒).

我设法让两个recaptchas工作,他们都正常运行.但是,当我尝试使用recaptcha.getResponse()或使用recaptcha.render('callback')方法时,它不会返回JSON,尽管在规范中这样说.这是有点

响应是JSON对象

{
    "success": true|false,
    "error-codes": [...]   // optional
}
Run Code Online (Sandbox Code Playgroud)

我在返回的数据中没有像这样远程获取任何内容.相反,它看起来像 Base64编码,但失败了我尝试过的任何解码器.看起来像这样

03AHJ_VuvWh4kgzEcKC_TBcc_BQjLucuL6g5tKXwYJT ......(此后更多)

这是我执行recaptchas的代码.它可能看起来很混乱,但这只是原型设计.谁能看出我做错了什么?我想我完全遵循了规范.

HTML(为简洁而剪裁)

<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

<div id="div_signup_recaptcha"></div>
<div id="div_forgotdetail_recaptcha"></div>
Run Code Online (Sandbox Code Playgroud)

JS/jQuery的

var grecaptchaSignup, grecaptchaForgotDetail;
var verifyForgotDetailCallback = function (response) {
    console.log(response);
}

var verifySignupCallback = function (response) {
    console.log(response);
}

var onloadCallback = function () {
    grecaptchaSignup = grecaptcha.render('div_signup_recaptcha', {
        'sitekey': 'mykey',
        'callback': verifySignupCallback
    });
    grecaptchaForgotDetail = grecaptcha.render('div_forgotdetail_recaptcha', {
        'sitekey': 'mykey',
        'callback': verifyForgotDetailCallback
    });
};
Run Code Online (Sandbox Code Playgroud)

Mig*_*ade 5

好吧,我是个白痴.

我以为我已经正确阅读了规范,结果我错过了对这个URL的基本调用

https://www.google.com/recaptcha/api/siteverify?secret=your_secret&response=response_string&remoteip=user_ip_address

插入我的私钥和编码响应后,我得到了我的JSON对象.

希望这能解决我职位上其他人的困惑:(