thinkPhp6 生成验证码API接口
2022-11-24 11:10:29
221
{{single.collect_count}}

第一步:使用Composer安装think-captcha扩展包

composer require topthink/think-captcha

第二步: 设置路由

Route::get('captcha/:id','\\think\\captcha\\CaptchaController@index');Route::get('captcha','Captcha/captcha');
第三步:控制器创建方法
public function captcha(Request $request){$id = mt_rand(100000, 999999);$uniqid = uniqid("$id");//返回数据 验证码图片路径、验证码标识$data = ['src' => $request->domain().captcha_src($uniqid),'uniqid' => $uniqid];return json(['code'=>200,'msg'=>'success','data'=>$data]);}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}