## **全局参数说明**
参数 | 备注
---|---
**{SERVER_ID}** | 配置文件中的服务器ID
**{CHILD_ID}** | 配置文件中的服务器ID
## **请求队列总览**
队列名称 | 备注
---|---
queue.accountLogin_**{SERVER_ID}** | 账号密码登录
queue.get_qrcode_**{SERVER_ID}** | 获取登录二维码
queue.logout_**{SERVER_ID}**_**{CHILD_ID}** | 退出登录
queue.reconnect_**{SERVER_ID}**_**{CHILD_ID}** | 断线重连
<br>
### **账号密码登录**
* 请求队列名:queue.accountLogin_{SERVER_ID}
* 请求参数:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| msg | <code>Map</code> | 队列传输参数类型 | true
| [msg.loginer] | <code>String</code> | 平台账号ID | true
| [msg.uin] | <code>String</code> | 微信号uin | true
| [msg.userName] | <code>String</code> | 微信号,wxid_xxxx | true
| [msg.account] | <code>String</code> | 登录的微信号/手机号 | true
| [msg.password] | <code>String</code> | 密码 | true
* Example
```
queueName = "queue.accountLogin_{SERVER_ID}"
map.put("loginer", "123");
map.put("uin", "12345678");
map.put("userName", "wxid_xxxxxxx");
map.put("account", "13888888888");
map.put("password", "123456789");
jmsTemplate.send(queueName, map);
```
> 备注:处理成功后会向广播队列"topic.accountLogin"推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)]
<br>
<br>
### **获取二维码**
* 请求队列名:queue.get_qrcode_{SERVER_ID}
* 请求参数:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| msg | <code>Map</code> | 队列传输参数类型 | true
| [msg.loginer] | <code>String</code> | 平台账号ID | true
| [msg.uin] | <code>String</code> | 微信号uin | false
| [msg.userName] | <code>String</code> | 微信号,wxid_xxxx | false
* Example
```
queueName = "queue.get_qrcode_{SERVER_ID}"
map.put("loginer", "123");
map.put("uin", "12345678");
map.put("userName", "wxid_xxxxxxx");
jmsTemplate.send(queueName, map);
```
> 处理成功后会向topic.qrcode推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)]
<br>
<br>
### **退出登录**
* 请求队列: queue.logout_{SERVER_ID}_{CHILD_ID}
* 请求参数:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| msg | <code>Map</code> | 队列传输参数类型 | true
| [msg.loginer] | <code>String</code> | 平台账号ID | true
| [msg.uin] | <code>String</code> | 微信号uin |
| [msg.userName] | <code>String</code> | 微信号,wxid_xxxx |
| [msg.authKey] | <code>String</code> | 授权key |
**Example**
```
queueName = "queue.logout_{SERVER_ID}_{CHILD_ID}"
map.put("loginer", "123");
//map.put("uin", "12345678");
//map.put("userName", "wxid_xxxxxxx");
//map.put("authKey", "XXXXXXX");
jmsTemplate.send(queueName, map);
```
处理成功后会向topic.qrcode推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)]
<br>
<br>
### **断线重连**
* 请求队列: queue.reconnect_{SERVER_ID}_{CHILD_ID}
* 请求参数:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 队列传输参数类型 | true
| [json.loginer] | <code>String</code> | 平台账号ID | true
| [json.uin] | <code>String</code> | 微信号uin |
| [json.cmdId] | <code>String</code> | 指令ID |
* Example
```
queueName = "queue.accountLogin_{SERVER_ID}"
JSONObject json = new JSONObject();
json.put("loginer", "123");
json.put("uin", "12345678");
json.put("cmdId", "xxxxxxx");
jmsTemplate.send(queueName, json);
```
> 在微信号长时间登录过程中,可能会出现假死的情况,此时需要进行一次断线重连
,请求完毕后等待30s,看是否恢复正常.
<br>
<br>
## **登录相关(订阅消息回推)**
### **账号密码登录结果**
* 请求队列topic.accountLogin
> 备注:账号密码登录会有较为严格的安全限制,需要在受信任的设备上登录才能跳过验证.因此目前强制要求先进行一次扫码登录,然后利用该设备进行帐号密码登录.
* response example:
- [x] 设备未初始化
```
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", 10000);
jsonObject.put("account", account);
jsonObject.put("loginer", loginer);
jsonObject.put("content", "未在系统初始化该微信,为了避免验证,请先进行扫码登录");
topicProducer.sendMapMessage("topic.accountLogin", jsonObject.toJSONString());
```
- [x] 登录失败
```
json:
{
"cancel": "",
"delayConnSec": "0",
"countdown": "0",
"dispSec": "0",
"title": "",
"content": "系统检测到环境存在异常,为了你的帐号安全, 请轻触“确定”进行安全验证。",
"url": "https://weixin110.qq.com/security/readtemplate?t=login_verify_entrances/w_tcaptcha&wechat_real_lang=zh_CN&aid=2000000038&clientype=1&lang=2052&apptype=undefined&captype=7&disturblevel=1§icket=1_70954702503759442260391174630142",
"loginer": "18",
"action": "1",
"showType": "8",
"ok": "",
"account": "cgq0824",
"status": -106,
"MTYPE": "accountLogin"
}
topicProducer.sendMapMessage("topic.accountLogin", jsonObject.toJSONString());
```
- [x] 登录成功
```
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", 0);
jsonObject.put("account", account);
jsonObject.put("loginer", loginer);
jsonObject.put("content", "登录成功");
topicProducer.sendMapMessage("topic.accountLogin", jsonObject.toJSONString());
```
### **二维码结果**
* 队列名称:topic.qrcode
> qrCode字段是base64的图片,前端在展示的时候需要拼接[data:image/png;base64,],然后用img标签进行展示.如果是写入文件则需要decode.
* response example:
```
{
"loginer": "18",
"qrCode": "xxxxxx",
"event": "qrcode",
"uuid": "PkaKPAteti"
}
```
##### topic.scan => 扫码结果/登录结果
获取二维码后后台自动进行二维码状态检测,并会在状态变更的时候向topic推送.根据qrcode中的uuid进行匹配.
response example:
- [x] 已扫码,等待确认(status=1)
```
{
"msg": "已扫码,请在手机端确认登陆...",
"loginer": "18",
"head_url": "http://wx.qlogo.cn/mmhead/ver_1/E7c9AFFte1iaSgIE9jCOTAGcw3iaKe23srGc7ib3b6CcnuqF5ibKAbUD05qqAcsxKZVITjwcwToOJXmDlmdCGyz6X258nTfTuKugdzicALQ4Bm4w/0",
"nick_name": "枫叶",
"event": "scan",
"uuid": "kCBwBqhuIr",
"status": 1
}
```
- [x] 已确认(status=2)
- [x] 手机端已取消登陆(status=4)
```
{
"msg": "手机端已取消登陆!",
"loginer": "18",
"head_url": "http://wx.qlogo.cn/mmhead/ver_1/E7c9AFFte1iaSgIE9jCOTAGcw3iaKe23srGc7ib3b6CcnuqF5ibKAbUD05qqAcsxKZVITjwcwToOJXmDlmdCGyz6X258nTfTuKugdzicALQ4Bm4w/0",
"nick_name": "枫叶",
"event": "scan",
"uuid": "kCBwBqhuIr",
"status": 4
}
```
- [x] 二维码过期(status=-2007)
```
{
"msg": "二维码已过期!",
"loginer": "18",
"head_url": "",
"nick_name": "",
"event": "scan",
"uuid": "PkaKPAteti",
"status": -2007
}
```
##### topic.logout => 退出登录通知
response example:
```
{
"uin": "xxx",
"mqType": 1100
}
```
