Wechat-Scan-Login
微信扫码登陆Web应用或者App应用获取临时授权Code
接口信息
GET / POST
api.vsaa.cn/api/wechat/scan_login/index.php
Method
GET / POST
分类
阴阳合一
Calls
46
KEY
无需 KEY
计费
免费
QPM
123/MIN
鉴权方式
无需密钥
作者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| action | string | 是 | 操作类: getApps(内置应用列表),getQrCode,checkLogin,getAccessToken,getUserInfo | getApps |
| type | string | 是 | 应用类型: app,web,(小程序|公众号|H5等后续增加) | web |
| appid | string | 是 | 应用appid | wx48db31d50e334801 |
| secret | string | 否 | 未知参数: 可选 (自行测试) | |
| redirect_uri | string | 否 | 类型为web 一般都要带上 | https://y.qq.com/n/ryqq/portal/index |
[
{
"name": "action",
"type": "string",
"required": true,
"description": "操作类: getApps(内置应用列表),getQrCode,checkLogin,getAccessToken,getUserInfo",
"example": "getApps"
},
{
"name": "type",
"type": "string",
"required": true,
"description": "应用类型: app,web,(小程序|公众号|H5等后续增加)",
"example": "web"
},
{
"name": "appid",
"type": "string",
"required": true,
"description": "应用appid",
"example": "wx48db31d50e334801"
},
{
"name": "secret",
"type": "string",
"required": false,
"description": "未知参数: 可选 (自行测试)",
"example": ""
},
{
"name": "redirect_uri",
"type": "string",
"required": false,
"description": "类型为web 一般都要带上",
"example": "https://y.qq.com/n/ryqq/portal/index"
}
]
返回示例
{
"code": 0,
"data": {
"uuid": "031usZkE1kcHFa12",
"appid": "wx48db31d50e334801",
"type": "web",
"qrcodeUrl": "https://open.weixin.qq.com/connect/qrcode/031usZkE1kcHFa12",
"redirect_uri": "https://y.qq.com/n/ryqq/portal/index",
"timestamp": 1788684465490
},
"message": "success"
}
详细文档
Wechat-Scan-Login
接口说明
Wechat-Scan-Login 接口用于通过微信扫码方式完成 Web 或 App 应用的登录授权流程。开发者调用该接口可获取二维码链接及授权状态,实现用户扫码登录功能。支持获取内置应用列表、生成二维码、查询登录状态及获取访问令牌等操作。
调用地址
/api/wechat/scan_login/index.php
请求方式
支持 GET 和 POST 方法。
鉴权说明
本接口无需任何鉴权密钥。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | string | 是 | 操作类型,可选值:getApps(获取内置应用列表)、getQrCode(获取二维码)、checkLogin(检查登录状态)、getAccessToken(获取访问令牌)、getUserInfo(获取用户信息) |
| type | string | 是 | 应用类型,可选值:app(App 应用)、web(Web 应用),小程序、公众号、H5 等后续增加 |
| appid | string | 是 | 微信开放平台分配的应用 AppID |
| secret | string | 否 | 预留参数,当前未使用,可留空 |
| redirect_uri | string | 否 | 授权回调地址,type 为 web 时建议填写,用于扫码授权后重定向返回 Code |
成功响应示例
{
"code": 0,
"data": {
"uuid": "031usZkE1kcHFa12",
"appid": "wx48db31d50e334801",
"type": "web",
"qrcodeUrl": "https://open.weixin.qq.com/connect/qrcode/031usZkE1kcHFa12",
"redirect_uri": "https://y.qq.com/n/ryqq/portal/index",
"timestamp": 1788684465490
},
"message": "success"
}
响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 状态码,0 表示成功 |
| message | string | 响应消息描述 |
| data | object | 业务数据对象 |
| data.uuid | string | 二维码唯一标识,用于后续轮询检查扫码状态 |
| data.appid | string | 微信应用 ID |
| data.type | string | 应用类型,枚举值:app、web |
| data.qrcodeUrl | string | 二维码跳转链接,用户扫码后访问此地址完成授权 |
| data.redirect_uri | string | 回调重定向地址,仅在 type 为 web 时生效 |
| data.timestamp | integer | 二维码生成时间戳(毫秒) |
错误响应示例
{
"code": 1,
"msg": "请求过于频繁",
"errcode": 11005
}
业务错误码说明
| errcode | 含义 |
|---|---|
| 11001 | 未提供调用密钥 |
| 11002 | 密钥错误 |
| 11003 | 密钥已禁用 |
| 11004 | 积分余额不足 |
| 11005 | 请求过于频繁(QPM 限制) |
| 11006 | 接口维护中 |
| 11007 | 接口已禁用 |
| 11008 | 接口不可用 |
| 11009 | 密钥校验暂不可用 |
| 11010 | 积分系统暂不可用 |
| 11011 | 收费接口须提供有效密钥 |
| 11012 | 鉴权方式错误 |
| 11013 | 接口不存在 |
| 11014 | ***地址无效 |
| 11015 | ***地址不允许 |
| 11016 | ***请求失败 |
| 11017 | 服务暂不可用 |
| 11018 | 请求方式不允许 |
| 11019 | 当前IP不在白名单内 |
| 11020 | 启用出口代理须提供有效密钥 |
| 11021 | 未配置可用出口代理 |
| 11022 | 出口代理不可用 |
| 11023 | 密钥已过期 |
| 11024 | 令牌分配积分不足 |
调用示例
终端 curl(bash)
curl -X POST "https://api.example.com/api/wechat/scan_login/index.php" \
-d "action=getQrCode&type=web&appid=wx48db31d50e334801&redirect_uri=https://example.com/callback"
PHP
注意事项
- 本接口无鉴权要求,但调用方需妥善保管
appid等参数,避免泄露至前端代码或公开仓库。 - 频率限制为每分钟约 123 次,超出限制将触发熔断,请合理控制请求间隔,批量调用建议做节流处理。
action参数决定操作流程,常见序列为getApps → getQrCode → checkLogin → getAccessToken → getUserInfo,各步骤需按序调用,跳过检查步骤可能导致后续流程失败。type=web时建议携带redirect_uri,用于授权回调;未携带时微信可能返回默认跳转地址或校验失败。secret为可选参数,当前版本用途未公开,非必填项可忽略。- 返回的
uuid与qrcodeUrl需配合前端扫码组件展示,扫码完成后通过action=checkLogin轮询状态,轮询间隔建议不低于 1 秒,避免高频请求触发限流。 - 所有接口调用均走 HTTPS 协议,请勿降级至 HTTP,否则可能导致请求被拦截或数据明文传输。
- 接口返回
code != 0时,以message字段为准排查原因,常见错误包括 appid 无效、type 不匹配、二维码已过期等。
快速上手
curl -X POST '/api/wechat/scan_login/index.php' \
-H 'Content-Type: application/json' \
-d '{"action":"getQrCode","type":"web","appid":"wx48db31d50e334801","redirect_uri":"https://y.qq.com/n/ryqq/portal/index"}'
# 返回 code=0 表示成功
在线测试
请求地址
api.vsaa.cn/api/wechat/scan_login/index.php
Method
参数
Response
等待中
// 结果将在此处显示