Recognizing captchas on Yii2

CAPTCHAFORUM

Administrator
1630329255797.png


The component provides the ability to easily work with all captcha recognition services that work according to common standards. I personally use ruCaptcha (prices are fine from 13 to 44 rubles per 1000 captcha).

Customization

Code:
...

'components' => [

    'captcha' => [

        'class' => 'jumper423\Captcha', //The component we'll be using

        'pathTmp' => '@common/captcha', //If we use a link on it as a captcha, then it is necessary to indicate where the files will be stored

        'apiKey' => '42eab4119020dbc729f657fef178r546', // API key

    ],

],

...

Links: - GitHub - Packagist - Site

Code:
$path = 'path/to/captcha.png';

if (\Yii::$app->captcha->run($path)) {

   $captcha = \Yii::$app->captcha->result();

} else {

   throw new Exception(\Yii::$app->captcha->error());

}



// or for links



$url = 'https://vk.com/captcha.php?sid=698254154192&s=1';

if (\Yii::$app->captcha->run($url)) {

   $captcha = \Yii::$app->captcha->result();

} else {

   throw new Exception(\Yii::$app->captcha->error());

}