PHP code example of randock / anti-captcha-client
1. Go to this page and download the library: Download randock/anti-captcha-client 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/ */
randock / anti-captcha-client example snippets
use Randock\AntiCaptcha\Client;
use Randock\AntiCaptcha\Task\ImageToTextTask;
use Randock\AntiCaptcha\Solution\ImageToTextSolution;
use Randock\AntiCaptcha\Exception\InvalidRequestException;
// create a new client
$client = new Client('<<API KEY>>');
// create the task to be send
$task = new ImageToTextTask();
// set the body
$task->setBody('<<BASE 64 of captcha>>');
//$task->setBodyFromFile($file);
try {
// send the task to anti-captcha.com
$task = $client->createTask($task);
do {
// wait a bit before (re)trying
sleep(2);
$taskResult = $client->getTaskResult($task);
} while ($taskResult->isProcessing());
/* @var ImageToTextSolution $solution */
$solution = $taskResult->getSolution();
// grab captcha text
$captcha = $solution->getText();
} catch (InvalidRequestException $exception) {
}