noCaptcha:防止自动重新加载以捕获失败的尝试

问题描述 投票:0回答:1

我正在将NoCaptcha集成到网站,并想自己捕获失败的验证码。遗憾的是,如果未正确解决,“验证码选择”(Captcha)验证码会立即重新加载。

因此,如果存在类似“选择所有显示咖啡的图像的挑战”,并且用户未正确选择所有相应的图像,则挑战将立即重新加载。但是我还是要发布数据(和表格),并自己检查验证码的正确性。

这里是其工作方式的一个简约示例。我敢肯定,如果验证码没有立即重新加载,它会起作用。

<?php
    require_once('recaptchalib.php');
    $publickey = "-----";
    $privatekey = "-----";
    try{
        if(isset($_POST['g-recaptcha-response'])){
            $captcha=$_POST['g-recaptcha-response'];
            if(!$captcha){ exit; }
            $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$privatekey."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
            if($response.success==false){
                // Do something
            } else {
                // Do something else
            }
        }
        else
        {
            ?>
            <html lang="en"> 
            <head> 
                <meta charset="utf-8" /> 
                <script src='https://www.google.com/recaptcha/api.js'></script>
            </head>
            <body>
                 <form method="post" action="thisfile.php">
                   <div class="g-recaptcha" data-sitekey="<?php echo $publickey; ?>"></div>
                   <input type="submit" value="Absenden" />
                 </form>
            </body>
            </html>
            <?php
        }

    } catch (Exception $e) {
        error_log($e->getMessage());
    }
?>

您知道防止自动重新加载的方法吗?

谢谢!

recaptcha
1个回答
0
投票

您应该知道reCaptcha背后的operations。 Google reCaptcha API(https://www.google.com/recaptcha/api.js)完成reCaptcha操作的所有工作;允许无网站所有者互动(网站验证除外)及其reCaptcha。

因此,您尝试prevent reCaptcha auto-reloading或类似操作会中断其操作或导致其对最终用户的不良行为。

© www.soinside.com 2019 - 2024. All rights reserved.