PHP code example of alancaptcha / php

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

    

alancaptcha / php example snippets


$api = new \AlanCaptcha\Php\AlanApi();
$challengeJWT = $api->challenge('YOUR-PUBLIC-SITEKEY');

$api = new \AlanCaptcha\Php\AlanApi();
$challengeJWT = $api->challenge(siteKey: 'YOUR-PUBLIC-SITEKEY', difficulty: 19);

$api = new \AlanCaptcha\Php\AlanApi();
$isValid = $api->challengeValidate($yourPrivateApiKey, $challengeJWT, $solutions);

$alanMiddleware = new \AlanCaptcha\Php\Middleware\AlanCaptchaMiddleware();
$alanMiddleware->setApiKey('YOUR-PRIVATE-APIKEY')->setIncludePaths(['/\/api\/.*'/]);
shell
composer