PHP code example of lucsaarend / anticaptcha-php

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

    

lucsaarend / anticaptcha-php example snippets


#Set Api Key
Suport ENV use ANTICAPTCHA_KEY=YORK_KEY

#Use method setKey
#Example
$apiCaptcha = new AntiGate();
$apiCaptcha->setKey('MyKey');

$apiCaptcha = new RecaptchaV2();
$apiCaptcha->setVerboseMode(true);#Use to debug

//recaptcha key from target website
$apiCaptcha->setWebsiteURL("http://http.myjino.ru/recaptcha/test-get.php");
$apiCaptcha->setWebsiteKey("6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16");

//browser header parameters
$apiCaptcha->setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0");

if (!$apiCaptcha->createTask()) {
    $apiCaptcha->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
    return false;
}

$taskId = $apiCaptcha->getTaskId();

if (!$apiCaptcha->waitForResult()) {
    $apiCaptcha->debout("could not solve captcha", "red");
    $apiCaptcha->debout($apiCaptcha->getErrorMessage());
} else {
    $recaptchaToken =   $apiCaptcha->getTaskSolution();
    echo "\ntoken result: $recaptchaToken\n\n";
}
bash
"lucsaarend/anticaptcha-php": "^1.0"
bash
composer