二维码生成
生成好看的二维码:支持文本、网址、电话、邮箱、短信、WiFi、名片
调用地址:https://api.ynlskj.com.cn/gateway/qrcode
请求方法:GET
在其他地方怎么调用
- 请求地址用上面的调用地址,参数拼在网址后面,例如
?type=url&url=https%3A%2F%2Fapi.ynlskj.com.cn&style=elegant&label=%E4%BA%91%E8%83%BD+API - 方法用
GET - API Key 只能放在请求头
X-API-Key,不要写进网址,也不要写进 Query 框 - Key 在「个人中心 → API Key」里复制,登录后会自动填入你自己的 Key
参数说明
| 参数 | 位置 | 必填 | 说明 |
|---|---|---|---|
type | Query | 否 | text / url / phone / sms / email / wifi / vcard / geo。不传时按参数自动识别 |
text | Query | type=text 时必填 | 普通文本 |
url | Query | type=url 时必填 | 网址,可省略 https:// |
phone | Query | phone/sms 时必填 | 电话号码 |
email | Query | type=email 时必填 | 邮箱地址,可选 subject、body |
ssid / password | Query | wifi 时 ssid 必填 | WiFi 名称和密码,可选 auth=WPA/WEP/nopass |
name | Query | vcard 时必填 | 名片姓名,可选 phone、email、org、url |
lat / lng | Query | type=geo 时必填 | 也可直接传 geo=纬度,经度 |
style | Query | 否 | classic / rounded / elegant / mint,默认 elegant |
size | Query | 否 | 模块大小 4–16,默认 10 |
label | Query | 否 | 二维码下方文字 |
fg / bg | Query | 否 | 自定义颜色,如 #1f4f9a |
X-API-Key | Header | 是 | 你的 API Key |
类型示例
| 类型 | Query 示例 |
|---|---|
| 文本 | {"type":"text","text":"你好,云能 API","style":"mint"} |
| 网址 | {"type":"url","url":"https://api.ynlskj.com.cn","style":"elegant","label":"云能 API"} |
| 电话 | {"type":"phone","phone":"13800138000","style":"rounded"} |
| 短信 | {"type":"sms","phone":"13800138000","sms":"你好"} |
| 邮箱 | {"type":"email","email":"hello@example.com","subject":"合作"} |
| WiFi | {"type":"wifi","ssid":"Office","password":"pass123","auth":"WPA"} |
| 名片 | {"type":"vcard","name":"张三","phone":"13800138000","email":"a@b.com"} |
| 位置 | {"type":"geo","lat":"39.9042","lng":"116.4074"} |
返回说明
| 字段 | 说明 |
|---|---|
ret | ok 成功,err 失败 |
data.image | 可直接用于 img 的 Data URI,便于预览和下载 |
data.svg | 二维码 SVG 源码 |
data.payload | 实际写入二维码的内容 |
data.type | 本次类型,如 url / phone |
msg | 本站提示,如「次数充足,剩余 99 次」或「次数不足,剩余 0 次」 |
remain_quota | 本次调用后的剩余次数 |
可直接复制的代码
未登录时示例只显示「你的密钥」。登录后会自动填入你自己的 Key,不会展示别人的。
<?php
$ch = curl_init('https://api.ynlskj.com.cn/gateway/qrcode?type=url&url=https%3A%2F%2Fapi.ynlskj.com.cn&style=elegant&label=%E4%BA%91%E8%83%BD+API');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: 你的密钥'],
]);
echo curl_exec($ch);
请求参数演示
{
"type": "url",
"url": "https://api.ynlskj.com.cn",
"style": "elegant",
"label": "云能 API"
}
响应演示
{
"ret": "ok",
"data": {
"type": "url",
"payload": "https:\/\/api.ynlskj.com.cn",
"style": "elegant",
"format": "svg",
"svg": "<svg>...<\/svg>",
"image": "data:image\/svg+xml;base64,..."
},
"msg": "次数充足,剩余 99 次",
"remain_quota": 99
}