Captcha Solution Simple API Client for Yii2

CAPTCHAFORUM

Administrator
yii2-release[1].png

The 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:
// find the module

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

// create a request
$ req = $ module-> captchaRequest ([
     'textCaptcha' => 'Hello'
]);

// send
$ res = $ req-> send ();

// check the status of the request
if (! $ res-> status) {

     throw new Exception ('Error:'. $ res-> request);
}

// get the order id
$ id = (int) $ res-> request;

Getting the solution:
Code:
// request for a solution
$ req = $ module-> resultRequest ([
     'action' => ResultRequest :: ACTION_GET,
     'id' => $ id
]);

// send
$ res = $ res-> send ();

// check the status of the request
if ($ res-> status) {
     echo 'Result:'. $ res-> request;
}

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