网站验证码有许多种,传统的图片验证码,现在比较流行的滑动拼图验证码。
在某网站看到有使用腾讯验证码的,顺便研究了一下。
从接入指引进入 腾讯验证码
首先创建场景。得到分配的appid, 和secret。
在你的网页引入js
在你页面需要点击验证的元素加入
id=”TencentCaptcha”
data-appid=”你的appid”
data-cbfn=”callback”
比如
加入js
服务端以php代码为例
http_post_data($url, $data); //echo $res; $j=json_decode($res); $rep= $j->response; //echo $rep; if($rep!=1) { $this->assign('error','验证码错误 Wrong Capcha.'.$j->err_msg); $this->display(); exit(); } // TODO 你原先的登录逻辑
至此,集成完毕。