騰訊防水牆(滑動驗證碼)的簡單使用 https://007.qq.com

在線體驗:https://007.qq.com/online.htmlhtml

快速開始:https://007.qq.com/quick-start.htmlui

簡單使用:spa

1. 引入 JScode

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

2. 寫一個JS方法orm

// 騰訊防水牆 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. 頁面的某個按鈕調用這個方法。htm

4. 後臺方法(略)對象

相關文章
相關標籤/搜索