PHP code example of andkab / php-turnstile
1. Go to this page and download the library: Download andkab/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/ */
andkab / php-turnstile example snippets
use andkab\Turnstile\Turnstile;
$turnstile = new Turnstile('secret key');
$verifyResponse = $turnstile->verify($_POST['cf-turnstile-response'], $_SERVER['REMOTE_ADDR']);
if ($verifyResponse->isSuccess()) {
// successfully verified captcha resolving
} elseif ($verifyResponse->hasErrors()) {
foreach ($verifyResponse->errorCodes as $errorCode) {
echo $errorCode . '\n';
}
} else {
// unknown reason of failure resolving of captcha
}
bash
composer