PHP code example of hexageek1337 / recaptcha-codeigniter4

1. Go to this page and download the library: Download hexageek1337/recaptcha-codeigniter4 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/ */

    

hexageek1337 / recaptcha-codeigniter4 example snippets


public $recaptcha_site_key = '';
public $recaptcha_secret_key = '';
public $recaptcha_lang = 'id';

echo $this->recaptcha->getWidget();

echo $this->recaptcha->getWidget(array('data-theme' => 'dark'));

echo $this->recaptcha->getWidget(array('data-theme' => 'dark', 'data-type' => 'audio'));

echo $this->recaptcha->getScriptTag();

echo $this->recaptcha->getScriptTag(array('render' => 'explicit'));

echo $this->recaptcha->getScriptTag(array('render' => 'explicit', 'hl' => 'zh-TW'));

$captcha = $this->request->getPost('g-recaptcha-response');
$response = $this->recaptcha->verifyResponse($captcha);

if (isset($response['success']) and $response['success'] === true) {
    echo "You got it!";
}