PHP code example of vf92 / recaptcha-bitrix

1. Go to this page and download the library: Download vf92/recaptcha-bitrix library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vf92 / recaptcha-bitrix example snippets


use Vf92\ReCaptcha\ReCaptcha;
/** Подключаем Js просто - обычно хватает */
ReCaptcha::addJs(ReCaptcha::INIT_RECAPTCHA_BY_JS);

/** Подключаем Js async defer - обычно хватает */
ReCaptcha::addJsAsync(ReCaptcha::INIT_RECAPTCHA_BY_JS);

/** проверяем капчу */
$isChecked = ReCaptcha::checkCaptcha($secretKey);//bool

/** возвращает строку с капчей 
если аяксом грузится - подключит скрипт прямо в строку
можно добавить дополнительные классы
*/
ReCaptcha::getCaptchaStatic($key, $additionalClass = '', $isAjax = false)//string 

/** через конструктор */
$recaptcha = new ReCaptcha($key, $secretKet);
/** возвращает строку с капчей 
если аяксом грузится - подключит скрипт прямо в строку
можно добавить дополнительные классы
*/
$recaptcha->getCaptcha($additionalClass = '', $isAjax = false);//string
/** возвращает публичный ключ */
$recaptcha->getParams();//array
/** проверяем капчу можно явно передать значение капчи*/
$recaptcha->check($recaptcha='');//bool