letraceursnork / sdkaptcha
Unofficial SDK bundle for different external CAPTCHA providers
v1.0.0
2025-07-11 17:00 UTC
Requires
- php: >=5.5
- ext-json: *
- guzzlehttp/guzzle: >=4.0
- letraceursnork/captcha-verifier: 0.1.0
- psr/http-client: ^1.0
- teapot/status-code: ^1.0|^2.0
Requires (Dev)
- avto-dev/php-cs-fixer: ^1.6
- fakerphp/faker: ^1.24
- php-coveralls/php-coveralls: ^0.1.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.2
README
Unofficial SDK for different Captcha external providers
Installation
composer require letraceursnork/sdkaptcha
Usage example
As described in this proposed CaptchaInterface, all of provided Captcha verifiers share common interface and their basic simple usage is:
// first we get User's token `token` from, say, front-end $token = 'User token from front-end'; $secret_recaptcha_key = 'recaptcha-secret-token'; $recaptcha = new \LeTraceurSnork\SDKaptcha\ReCaptcha\ReCaptcha($secret_recaptcha_key); $recaptcha_response = $recaptcha->verify($token); if ($recaptcha_response->isSuccess()) { // ... ReCaptcha successfully passed } $secret_hcaptcha_key = 'hcaptcha-secret-token'; $hcaptcha = new \LeTraceurSnork\SDKaptcha\HCaptcha\HCaptcha($secret_hcaptcha_key); $hcaptcha_response = $hcaptcha->verify($token); if ($hcaptcha_response->isSuccess()) { // ... hCaptcha successfully passed } $secret_smartcaptcha_key = 'smart-captcha-secret-token'; $smart_captcha = new \LeTraceurSnork\SDKaptcha\SmartCaptcha\SmartCaptcha($secret_smartcaptcha_key); $smartcaptcha_response = $smart_captcha->verify($token); if ($smartcaptcha_response->isSuccess()) { // ... Smart Captcha successfully passed } // ... you got the idea // Please see basic interface for details // ... or see specific Captcha verifier for specific details, especially their inner fields, like getScore() for ReCaptcha