我不能让reCAPTCHA v3在我的网站上工作。我已经把正确的代码从谷歌reCAPTCHA v3网站,但它显示“错误的网站所有者:无效的网站密钥”在右下角。
我只有7岁,如果我错过了什么,请放轻松
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
<body>
<button class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'>Submit</button>
<script>
function onClick(e) {
e.preventDefault();
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token) {
// Add your logic to submit to your backend server here.
});
});
}
</script>
</head>
</body>
</html>
然后,我尝试了reCAPTCHA v2复选框,同样发生了同样的事情。不过,“网站所有者错误:网站密钥无效”现在位于左上角:
<!DOCTYPE html>?
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
<body>
<form action="?" method="POST">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
var onloadCallback = function() {
alert("grecaptcha is ready!");
};
</script>
</head>
</body>
</html>
发布于 2020-05-29 19:16:10
我试过你提到的reCAPTCHA v3的代码。
"COPY SITE KEY"
.file:///E:/Personal%20Data/stackoverflow/recapcha.html
for example if your website is: https://www.testingrecapcha.com/ then add testingrecapcha.com in domains of rechapcha configurations. (to reach admin console of recapcha, use this: https://www.google.com/recaptcha/admin and select your relevant site and click on settings icon).
https://stackoverflow.com/questions/62083503
复制相似问题