验证码生成

随机汉字、成语、图片验证码生成与校验,适用于登录注册、表单防刷等场景

POST JSON 或 GET。
生成:action=generate,type 支持 char(汉字)、idiom(成语)、image(图片)。
验证:action=verify,传入 captcha_id 与 code。

调用地址:https://api.ynlskj.com.cn/gateway/captcha

请求方法:POST

在其他地方怎么调用

  1. 请求地址用上面的调用地址,把 JSON 放在请求体里
  2. 方法用 POST
  3. API Key 只能放在请求头 X-API-Key,不要写进网址,也不要写进 Query 框
  4. Key 在「个人中心 → API Key」里复制,登录后会自动填入你自己的 Key

参数说明

参数位置必填说明
actionQuery示例值:generate
typeQuery示例值:image
lengthQuery示例值:4
image_formatQuery示例值:png
X-API-KeyHeader你的 API Key

返回说明

字段说明
retok 成功,err 失败
data接口返回数据
msg本站提示,如「次数充足,剩余 99 次」或「次数不足,剩余 0 次」
remain_quota本次调用后的剩余次数

可直接复制的代码

未登录时示例只显示「你的密钥」。登录后会自动填入你自己的 Key,不会展示别人的。

<?php
$ch = curl_init('https://api.ynlskj.com.cn/gateway/captcha');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['X-API-Key: 你的密钥', 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => '{
    "action": "generate",
    "type": "image",
    "length": 4,
    "image_format": "png"
}',
]);
echo curl_exec($ch);

请求参数演示

{"action":"generate","type":"image","length":4}

响应演示

{"ret":"ok","data":{"action":"generate","type":"image","format":"image","captcha_id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","expires_in":300,"length":4,"image":"data:image/svg+xml;base64,...","width":184,"height":56}}

在线调试

登录后可在线调试。调试会真实调用网关并消耗次数。

去登录