PHP SDK
Official PHP SDK for CaptchaSonic
PHP SDK
Our PHP SDK streamlines CaptchaSonic integration for PHP applications. It handles HTTP requests, polling, and error management automatically.
Installation
Install using Composer:
composer require captchasonic/captchasonic-php
Implementation
<?php
require 'vendor/autoload.php';
use CaptchaSonic\Client;
use CaptchaSonic\Tasks\RecaptchaV2Task;
// 1. Initialize Client
$client = new Client('YOUR_API_KEY');
try {
// 2. Create Task
$task = new RecaptchaV2Task([
'websiteURL' => 'https://example.com',
'websiteKey' => '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-'
]);
// 3. Solve (auto-polling)
$solution = $client->solve($task);
echo "Token: " . $solution->gRecaptchaResponse;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}