PHP code example of kagurati / captchautils

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

    

kagurati / captchautils example snippets


...
use CAPTCHAUtils\Turnstile;
...
private string $yourTunrstileSecretKey = '1234abcd';
...
public function checkThisUser($clientResponseString, $userIP = null, $idempotencyKey = null) {
        $check = new Turnstile($this->yourTurnstileSecretKey)->verify($clientResponseString, $userIP, $idempotencyKey);
        if ($check[0]) {
                # User is a real human!
        } else {
                # User probably isn't a real human.
                $errors = $check[1]['error-codes'];
        }
}

...
use CAPTCHAUtils\hCaptcha;
...
private string $yourhCaptchaSecretKey = '1234abcd';
...
public function checkThisUser($clientResponseString, $userIP = null, $expectedSiteKey = null) {
        $check = new hCaptcha($this->yourhCaptchaSecretKey)->verify($clientResponseString, $userIP, $expectedSiteKey);
        if ($check[0]) {
                # User is a real human!
        } else {
                # User probably isn't a real human.
        }
}