dicr / yii2-anticaptcha-simple

CAPTCHAFORUM

Administrator
vasplus_blog_captcha_script[1].gif

Captcha Solution Simple API Client for Yii2

Simple Rest request protocol is supported by services such as:
  • rucaptcha.com
  • 2captcha.com
Customization
Code:
'modules' => [

    'anticaptcha' => [

        'class' => dicr\anticaptcha\simple\AntiCaptchaSimpleModule::class,

        'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

    ]

]

Usage
Request to solve simple text captcha:

Code:
$module = Yii::$app->getModule('anticaptcha');



$req = $module->captchaRequest([

    'textCaptcha' => 'Привет'

]);



$res = $req->send();



if (! $res->status) {

    throw new Exception('Ошибка: ' . $res->request);

}



$id = (int)$res->request;

Getting the solution:

Code:
$req = $module->resultRequest([

    'action' => ResultRequest::ACTION_GET,

    'id' => $id

]);



$res = $res->send();



if ($res->status) {

    echo 'Результат: ' . $res->request;

}

Documentation https://packagist.org/packages/dicr/yii2-anticaptcha-simple