## **全局參數說明**
參數 | 備注
---|---
**{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
}
```