P
P
Pavel Sidorov2021-01-13 14:21:29
1C-Bitrix
Pavel Sidorov, 2021-01-13 14:21:29

Why does the missing-input-response google recaptcha 2 error occur?

Others why an error occurs when installing captcha I

use the Bitrix management system
What I do
1. In php init I connect secret keys and captcha files

@require_once 'include/autoload.php';
define("RE_SITE_KEY","6LcM1BATAAAAAL8WJjzVauo8oR1c8df334CbJWw7Me8uC");
define("RE_SEC_KEY","6LcM1BATAAAAAAk3_djGibj67kf5342fdfAHMGPYJuxl1yk");

2. I include captcha in the component template
<script src='https://www.google.com/recaptcha/api.js?hl=ru'></script>
  <div class="g-recaptcha" data-sitekey="<?=RE_SITE_KEY?>"></div>

3. In the component I do a check
$recaptcha = new \ReCaptcha\ReCaptcha(RE_SEC_KEY);
  $resp = $recaptcha->verify($_REQUEST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
 
    if (!$resp->isSuccess()){
      foreach ($resp->getErrorCodes() as $code) {
        echo "Ошибка! Проверка не пройдена.";
        echo $code;
        return;
      }
  }


gives an error missing-input-response
How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question