php - Google Invisible reCaptcha 未按预期工作
问题描述
我们在登陆页面“注册和登录”有两个表单,我们必须在两个表单上集成不可见的验证码。
下面是在 body 标签关闭上方加载的脚本:
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
注册和登录表单通过主页上的引导模式呈现。所以,我必须使用脚本中提到的单个回调来管理这两种表单。有时它工作,有时没有。!
当我执行以下脚本时,它开始显示挑战框,因为我已经附上了屏幕截图。setTimeout(function(){ grecaptcha.execute(login_captcha); },1200);
下面是我的 JS 代码:
function loadGoogleCaptcha(captcha_selector){
var onloadCallback = function(captcha_selector) {
if (captcha_selector=='login_captcha'){
login_captcha = grecaptcha.render(captcha_selector, {'sitekey' : sitekey, 'callback' : captchaLoginCallback});
} else if (captcha_selector=='signup_captcha'){
signup_captcha = grecaptcha.render(captcha_selector, {'sitekey' : sitekey, 'callback' : captchaSignupCallback});
}
};
onloadCallback(captcha_selector);
if (captcha_selector=='login_captcha'){
setTimeout(function(){ grecaptcha.execute(login_captcha); }, 1200);
} else if (captcha_selector=='signup_captcha'){
setTimeout(function(){ grecaptcha.execute(signup_captcha); }, 1200);
}
}
function captchaLoginCallback(token){
grecaptcha.execute(login_captcha);
//var captcha_response = grecaptcha.getResponse(login_captcha);
//console.log('Login: '+token+' === '+captcha_response);
}
function captchaSignupCallback(token){
grecaptcha.execute(signup_captcha);
//var captcha_response = grecaptcha.getResponse(signup_captcha);
//console.log('Signup: '+token+' === '+captcha_response);
}
我希望现在我的查询很清楚
我做错了什么。任何帮助,将不胜感激。
谢谢
解决方案
推荐阅读
- python - 在 pandas Dataframe 上调用 seaborn 的 pairplot 时不显示图
- woocommerce - 当订阅被取消、过期或暂停时向客户发送电子邮件
- php - Upload PDF on CodeIgniter 3.1.9
- scala - What happens when return a lazy val from a function in Scala?
- html - 仅在 Chrome 中,按钮“标题”工具提示存在分秒重绘问题
- ios - 如何快速将 UIViewController 添加到 UIScrollView 中?
- c# - Asp.Net 发送 Outlook 电子邮件并获取此 5.7.57 SMTP 客户端未经过身份验证以在 MAIL FROM 期间发送匿名邮件
- php - 如何修复 Wordpress 中的“警告:为 foreach() in...提供的参数无效”错误
- regex - 如果写出或 2 位数字,则匹配“状态”文本?
- git - 如何在 GitLab 的合并请求中请求 CLA 签名?