返回首页

接口使用说明

本服务提供以下 HTTP 接口,均为服务器本地生成二维码,无外部依赖。所有接口支持 CORS 跨域调用。

GET POST 单个二维码生成
GET https://qrcode.obbbo.cn/index.php?action=qr?content=要编码的内容
POST https://qrcode.obbbo.cn/index.php?action=qr body: {"content":"要编码的内容"}
content 必填,其余参数有默认值。支持 GET 查询串和 POST 请求体两种调用方式。返回 PNG 图像二进制流,可直接保存或用于页面展示。
参数类型必填默认值说明
content string 必填 - 要编码的内容,最长 2000 字符
size int 选填 300 图像像素尺寸(100–1000)
color string 选填 #000000 前景色(6 位 hex)
bgColor string 选填 #ffffff 背景色(6 位 hex)
# GET 调用(浏览器直接访问) https://qrcode.obbbo.cn/index.php?action=qr?content=https://example.com # GET 带可选参数 https://qrcode.obbbo.cn/index.php?action=qr?content=https://example.com&size=400&color=4f46e5 # cURL POST curl -X POST -H "Content-Type: application/json" \ -d '{"content":"https://example.com"}' \ https://qrcode.obbbo.cn/index.php?action=qr -o code.png # JavaScript fetch fetch('/index.php?action=qr', { method: 'POST', headers: { "Content-Type": "application/json" }, body: JSON.stringify({ content: "https://example.com" }) }).then(r => r.blob()).then(blob => { const url = URL.createObjectURL(blob); document.getElementById('my-qr').src = url; });
GET 批量二维码生成
https://qrcode.obbbo.cn/index.php?action=qr-batch&content=line1\nline2
多行内容用 \n 分隔,每行生成一张二维码。返回 JSON,包含每张图的 Base64 编码。单次最多 50 行。
参数类型必填默认值说明
content string 必填 - 多行文本,换行分隔,每行一个二维码内容
size int 选填 300 图像像素尺寸
color string 选填 #000000 前景色
bgColor string 选填 #ffffff 背景色
format string 选填 png 输出格式:png 或 svg
max int 选填 20 最多生成数量(1–50)
# 返回结构 { "success": true, "total": 3, "success_count": 3, "results": [ { "index": 1, "content": "line1", "success": true, "data": "data:image/png;base64,..." }, { "index": 2, "content": "line2", "success": true, "data": "data:image/png;base64,..." } ] }