标签: invisible-recaptcha

如何在表单提交后重置recaptcha?

这是我的PHP代码:

    function post_captcha($user_response) {
    $fields_string = '';
    $fields = array(
        'secret' => '',
        'response' => $user_response
    );
    foreach($fields as $key=>$value)
    $fields_string .= $key . '=' . $value . '&';
    $fields_string = rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);
}
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
      die('MF005');
} else {
if ($mail->send()) { 
$send_arEmail = $autoresponder->Send();
}}
Run Code Online (Sandbox Code Playgroud)

这是我的JavaScript代码:

<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function …
Run Code Online (Sandbox Code Playgroud)

javascript php recaptcha invisible-recaptcha

3
推荐指数
1
解决办法
6383
查看次数

如何验证reCAPTCHA V2 Java(Servlet)

这是一个Q&A风格的帖子,我将发布问题和答案.主要原因是我花了很多时间搜索验证recaptcha V2的最简单方法.因此,我将分享我的知识,以避免开发人员进一步浪费时间.

如何使用Java对Google reCAPTCHA V2Invisible reCAPTCHA进行服务器端验证

java validation servlets recaptcha invisible-recaptcha

3
推荐指数
1
解决办法
8956
查看次数

新的ReCaptcha(隐形)不起作用

我正在尝试实现新的隐形reCaptcha,但它无法正常工作.

首先,事件艰难我用"隐形"选项创建了一个新密钥,更改了我的应用程序中的密钥,当我查看我的控制台时,我可以看到这个请求:

https://www.google.com/recaptcha/ api2/anchor?k = .....

我认为这不是正确的api,对吧?

我的导入部分的代码是这样的:

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

哪个是正确的根据文件......

其次,我选择将验证码放在div中(根据文档可以):

<div id="captchaSignup" class="g-recaptcha" data-size="invisible" data-badge="inline"></div>

我也使用render函数来声明回调和site-key:

grecaptcha.render(document.getElementById('captchaSignup'), { 'sitekey' : '...', 'callback' : function(response) {$rs.validCaptcha=response;$s.$apply()} });

这可以作为验证码解决方案,但不是隐形的,因为它仍然显示框.我知道我也必须使用执行功能,但由于我仍然看到了这个盒子,我想我还没有进入那个阶段......有人能帮帮我吗?

recaptcha invisible-recaptcha

2
推荐指数
1
解决办法
7307
查看次数

不可见的reCAPTCHA发送具有多种形式的空g-captcha-chasponse

我正在尝试使用Google Invisible reCAPTCHA,但是g-recaptcha-response当我在同一页面中有多个表单时,它将发送POST参数为空。这是我的代码:

谷歌JS

<script src="//google.com/recaptcha/api.js?hl=pt-BR&onload=captchaCallback&render=explicit" async defer></script>
Run Code Online (Sandbox Code Playgroud)

表格1

<form action="/site/Contact/send" id="form1">
    <input type="text" name="nome" required>

    <div class="g-recaptcha"
        data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
        data-callback="form1Callback"
        data-size="invisible">
    </div>

    <button type="submit">Send</button>

</form>
Run Code Online (Sandbox Code Playgroud)

表格2

<form action="/site/Contact/send" id="form2">
    <input type="text" name="nome" required>

    <div class="g-recaptcha"
        data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
        data-callback="form2Callback"
        data-size="invisible">
    </div>

    <button type="submit">Send</button>
</form>
Run Code Online (Sandbox Code Playgroud)

我的JS(基于此答案

$(document).ready(function() {

    window.captchaCallback = function(){
        $('.g-recaptcha').each(function(index, el) {
            var attributes = {
                'sitekey'  : $(el).data('sitekey'),
                'size'     : $(el).data('size'),
                'callback' : $(el).data('callback')
            };

            grecaptcha.render(el, attributes);
        });
    };

    window.form1Callback = function(){
         $('#form1').submit(); …
Run Code Online (Sandbox Code Playgroud)

javascript forms jquery recaptcha invisible-recaptcha

2
推荐指数
2
解决办法
7213
查看次数

Formvalidation.io - 无法读取 null 的属性“classList”

使用 formvalidation.io 时,我的控制台总是出错。

在此处输入图片说明

我不知道这个错误的原因是什么。我还在某些网站上收到垃圾邮件,即使我使用的是 backendVerificationURL。我正在使用 Invisible ReCaptcha ( https://formvalidation.io/guide/plugins/recaptcha/ )

我的 HTML 表单:

                                <form id="contact" method="post" action="/vendor/contact-form.php">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group label-floating is-empty">
                                                <label class="bmd-label-floating">Naam</label>
                                                <input type="text" name="naam" id="naam" class="form-control">
                                                <span class="material-input"></span>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group label-floating is-empty">
                                                <label class="bmd-label-floating">Telefoonnummer</label>
                                                <input type="text" name="telefoon" id="telefoon" class="form-control">
                                                <span class="material-input"></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group label-floating is-empty">
                                        <label class="bmd-label-floating">Mailadres</label>
                                        <input type="email" name="email" id="email" class="form-control">
                                        <span class="material-input"></span>
                                    </div>
                                    <div class="form-group label-floating is-empty">
                                        <label for="bericht" class="bmd-label-floating">Uw bericht</label>
                                        <textarea name="bericht" …
Run Code Online (Sandbox Code Playgroud)

html javascript css formvalidation.io invisible-recaptcha

2
推荐指数
2
解决办法
2534
查看次数

Google Recaptcha V3 - 通过 URL 加载验证码时的小部件 ID

我正在我的网站上实施 Recaptcha V3,如果我的请求失败,我找不到重置令牌的正确方法。

按照文档,要加载重新验证码,我需要在我的页面上包含以下脚本:

<script src='https://www.google.com/recaptcha/api.js?render=MY_KEY'></script>
Run Code Online (Sandbox Code Playgroud)

此外,我将验证码令牌绑定到一个字段,以便在客户选择发送电子邮件时在我的后端进行验证:

    grecaptcha.ready(function() {
        grecaptcha.execute('MY_KEY', {
            action : 'homepage'
        }).then(function(token) {
            $("#recaptcha").val(token);
        });
    });
Run Code Online (Sandbox Code Playgroud)

所以我主要有两个步骤:

  1. 验证验证码
  2. 发送电子邮件

如果在第二步中发生某些错误,我无法找到重置页面上当前验证码的方法,因为如果我再试一次,它已经被验证,它不再有效。

我已经尝试过grecaptcha.reset(),但没有widgetId出现以下消息:Uncaught Error: No reCAPTCHA clients exist.

通过脚本渲染时如何获取小部件 ID?

javascript jquery recaptcha invisible-recaptcha recaptcha-v3

1
推荐指数
1
解决办法
3869
查看次数

提交表单时在不可见的验证码上出现未捕获的类型错误

我正在尝试通过Google实施新的隐形Recaptcha。

但是我有必要的输入,并且应该在recaptcha执行之前验证表格。

我在这样的recaptcha回调函数上遇到错误:

未捕获的TypeError:document.getElementById()提交不是函数

那么在验证和重新验证执行后如何提交表单?

HTML

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

<form id="form" action="?" method="post">
     Name: (required) <input id="field" name="field">
     <div id='recaptcha' class="g-recaptcha"
          data-sitekey="6LcAmBAUAAAAAFukLQIkOIICuBBxKEdn-Gu83mcH"
          data-callback="onSubmit"
          data-size="invisible"></div>
     <button id='submit'>submit</button>
   </form>
<script>onload();</script>
Run Code Online (Sandbox Code Playgroud)

Javascript

function onSubmit(token) {
  alert('Thanks ' + document.getElementById('field').value + '!');
  document.getElementById('form').submit(); // This is error line
}

function validate(event) {
  event.preventDefault();
  if (!document.getElementById('field').value) {
    alert("Please enter your name.");
  } else {
    grecaptcha.execute();
  }
}

function onload() {
  var element = document.getElementById('submit');
  element.onclick = validate;
}
Run Code Online (Sandbox Code Playgroud)

JSFiddle:http : //jsfiddle.net/dp1cLh28/6/

javascript jquery recaptcha invisible-recaptcha

0
推荐指数
2
解决办法
4041
查看次数