PHP code example of fluxsoft / php-turnstile

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

    

fluxsoft / php-turnstile example snippets


// e FluxSoft\Turnstile\Turnstile;

$turnstile = new Turnstile('secret key');
$verifyResponse = $turnstile->verify($_POST['cf-turnstile-response'], $_SERVER['REMOTE_ADDR']);

if ($verifyResponse->success) {
    // successfully verified captcha resolving
} else {
    if ($verifyResponse->hasErrors()) {
        foreach ($verifyResponse->errorCodes as $errorCode) {
            echo $errorCode . '\n'; 
        }
    } else {
        // unknown reason of failure resolving of captcha
    }
}
bash
composer