第四代行为验证码(YCaptcha V4), 使用机器学习, 在第三代验证码风控的基础上不断优化, 服务可以帮助您解决以下业务安全问题:
登录注册:有效防止撞库攻击、阻止注册机批量注册小号。
活动秒杀:有效拦截刷单操作,防止自动机刷取福利券。
点赞发帖:有效解决广告屠版、恶意灌水、刷票问题。
数据保护:有效防止自动机、爬虫盗取网页内容和数据。
目前第四代支持滑动验证/无感验证, 新验证将在不久后更新 (开学前勉强做完了QAQ)
DEMO地址: DEMO
步骤一: 引入验证码js, css (不可动态加载!)
xxxxxxxxxx<link rel="stylesheet" type="text/css" href="https://captcha.2zxz.com/css/YCaptcha.css"><script src="https://captcha.2zxz.com/js/YCaptcha.js"></script>步骤二: 创建验证
xxxxxxxxxxnew YCaptcha(VType, function OnSuccess(Ticket, Rand) { }, function OnFailed(Reason) { })推荐在<head>标签中加入
xxxxxxxxxx<meta name="viewport" content="width=device-width, initial-scale=1.0">参数说明
| 参数名 | 值类型 | 说明 |
|---|---|---|
| VType | Number | 验证类型 (0: 滑块验证, 1: 无感验证) |
| SuccessCB | Function | 成功时的回调函数 (Ticket, Rand) |
| FailCB | Function | 验证错误/用户关闭时的回调函数 (Reason) |
失败后Reason说明
| 值 | 说明 |
|---|---|
| CAPTCHA_CHALLENGING | 正在进行验证 |
| CAPTCHA_NOT_FOUND | 没有此验证类型 |
| CAPTCHA_CLOSED | 用户关闭验证 |
| BadCode | 验证服务出现错误, 建议创建一个新验证 |
xxxxxxxxxx<html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Web 前端接入示例</title> <!-- 验证码依赖! --> <link rel="stylesheet" type="text/css" href="https://captcha.2zxz.com/css/YCaptcha.css"> <script src="https://captcha.2zxz.com/js/YCaptcha.js"></script> <!-- 验证码依赖 End --> </head> <body> <button id="CaptchaVerify" type="button">验证</button> <script> document.getElementById('CaptchaVerify').onclick = function () { let VType = 0 // 验证类型 // 成功回调 function SuccessCB(Ticket, Rand) { // ...... } // 失败回调 function FailCB(Reason) { // ...... } new YCaptcha(VType, SuccessCB, FailCB) } </script> </body></html>
| 请求参数 | 值 |
|---|---|
| URL | captcha.2zxz.com/ticket |
| Method | POST |
| Content-Type | application/json |
以下参数全部必选
| 参数名称 | 类型 | 描述 |
|---|---|---|
| Ticket | String | 前端回调函数返回的用户验证票据 (Ticket) 验证一次后即销毁 |
| Rand | String | 前端回调函数返回的随机字符串 (Rand) |
| UA | String | 业务侧获取的用户UA |
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Number | 返回码 (1: 验证不通过, 2: 验证通过) |
| Info | JSON | 见下表 |
| 参数名称 | 类型 | 描述 |
|---|---|---|
| IsUASame | Number | UA是否相符 (0: 不相符, 1: 相符) |
| UIP | String | 验证侧获取的用户IP |
| CapT | Number | 验证类型 |
POST /ticket HTTP/1.1Host: captcha.2zxz.comContent-Type: application/json
{ "Ticket": "114514", "Rand": "xxxxx", "UA": "Mozilla/5.0 xxxxxxxxx"}