CAPTCHAFORUM
Administrator
![vasplus_blog_captcha_script[1].gif vasplus_blog_captcha_script[1].gif](https://captchaforum.com/data/attachments/1/1032-4acc7e7d7c2b2caed900fa06d5c43513.jpg)
Captcha Solution Simple API Client for Yii2
Simple Rest request protocol is supported by services such as:
- rucaptcha.com
- 2captcha.com
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