二维码生成

生成好看的二维码:支持文本、网址、电话、邮箱、短信、WiFi、名片

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

请求方法:GET

在其他地方怎么调用

  1. 请求地址用上面的调用地址,参数拼在网址后面,例如 ?type=url&url=https%3A%2F%2Fapi.ynlskj.com.cn&style=elegant&label=%E4%BA%91%E8%83%BD+API
  2. 方法用 GET
  3. API Key 只能放在请求头 X-API-Key,不要写进网址,也不要写进 Query 框
  4. Key 在「个人中心 → API Key」里复制,登录后会自动填入你自己的 Key

参数说明

参数位置必填说明
typeQuerytext / url / phone / sms / email / wifi / vcard / geo。不传时按参数自动识别
textQuerytype=text 时必填普通文本
urlQuerytype=url 时必填网址,可省略 https://
phoneQueryphone/sms 时必填电话号码
emailQuerytype=email 时必填邮箱地址,可选 subject、body
ssid / passwordQuerywifi 时 ssid 必填WiFi 名称和密码,可选 auth=WPA/WEP/nopass
nameQueryvcard 时必填名片姓名,可选 phone、email、org、url
lat / lngQuerytype=geo 时必填也可直接传 geo=纬度,经度
styleQueryclassic / rounded / elegant / mint,默认 elegant
sizeQuery模块大小 4–16,默认 10
labelQuery二维码下方文字
fg / bgQuery自定义颜色,如 #1f4f9a
X-API-KeyHeader你的 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"}

返回说明

字段说明
retok 成功,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
}

在线调试

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

去登录