mews/captcha 也适用于 API  
                            
                                                    
                        
                    
                    
  
                    
                    - 
在 CaptchasController 里引入 mews/captcha ... use Mews\Captcha\Captcha; public function store(CaptchaRequest $request, Captcha $captcha) { $captchaInfo = $captcha->create('flat', true); }
第二个参数是表示api调用,此时方法会返回图片验证码的信息数组
    [
      'sensitive' => $generator['sensitive'],
      'key' => $generator['key'],
      'img' => $this->image->encode('data-url')->encoded
    ]- 
在 VerificationCodesController 里验证图片二维码时可以调用 captcha_api_check 方法 if(!captcha_api_check($request->captcha_code, $captchaData['captchaKey'])) { Cache::forget($request->captcha_key); $this->response->errorUnauthorized('验证码错误'); }
 
           
         
             
                     
                     
             
             
             
           
           关于 LearnKu
                关于 LearnKu
               
                     
                     
                     粤公网安备 44030502004330号
 粤公网安备 44030502004330号 
 
推荐文章: