laravel-验证码(前后端分离)
1.安装
composer require mews/captcha
2.获取验证码接口
$data = Captcha::create('default', true); return $this->success($data);
3.验证接口
//用户输入的验证码内容 $code = 'czuu'; //获取验证码接口返回的key $key = '$2y$10$QcWWDaSscrJTxHYqxVQR/.OQxEBy20yA6cYmxeJTQjGZKqm3kBuOG'; if (!captcha_api_check($code, $key)) { return $this->fail(500, '验证码有误'); } return $this->success();