腾讯防水墙(滑动验证码)的简单使用 https://007.qq.com

在线体验:https://007.qq.com/online.html

快速开始:https://007.qq.com/quick-start.html

简单使用:

1. 引入 JS

<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>

2. 写一个JS方法

// 腾讯防水墙 https://007.qq.com
function submitFormWithCaptcha() {
    // 直接生成一个验证码对象
    var captcha = new TencentCaptcha('AppID', function (res) {
        console.log(res)
        // res(未通过验证)= {ret: 1, ticket: null}
        // res(验证成功) = {ret: 0, ticket: "String", randstr: "String"}
        if (res.ret === 0) {
                //票据
                //alert(res.ticket)  
                //随机串
                //alert(res.randstr)  
                submitForm();
        } 
    });
    // 显示验证码
    captcha.show(); 
}

3. 页面的某个按钮调用这个方法。

4. 后台方法(略)

 

posted on 2018-09-29 12:13  大豆男生  阅读(2699)  评论(0编辑  收藏  举报

导航