多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## **全局参数说明** 参数 | 备注 ---|--- **{SERVER_ID}** | 配置文件中的服务器ID **{CHILD_ID}** | 配置文件中的服务器子进程ID <br> ## **请求队列总览** 队列名称 | 备注 ---|--- queue.getContact_**{SERVER_ID}**_**{CHILD_ID}** | 获取好友详情 queue.searchContact_**{SERVER_ID}**_**{CHILD_ID}** | 搜索微信号/QQ号/手机号 queue.addContact_**{SERVER_ID}**_**{CHILD_ID}** | 添加好友 queue.addNew_**{SERVER_ID}**_**{CHILD_ID}** | 通过好友请求 queue.syncContact_**{SERVER_ID}**_**{CHILD_ID}** | 同步联系人 queue.modifyName_**{SERVER_ID}**_**{CHILD_ID}** | 修改备注名 queue.addChatRoomContact_**{SERVER_ID}**_**{CHILD_ID}** | 添加群成员为好友 <br> ### **获取好友详情** * 请求队列:queue.getContact_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | json | <code>JSONObject</code> | 队列传输参数类型 | true | [json.adminUserId] | <code>Long</code> | 平台账号ID | true | [json.uin] | <code>String</code> | 微信号uin | true | [json.userName] | <code>String</code> | 需要获取详情的好友或群成员微信号,wxid_xxxx | true | [json.chatRoomName] | <code>String</code> | 群ID,获取群成员时必填 | | [json.queueName] | <code>String</code> | 获取群成员时必填 | * Example ``` queueName = "queue.getContact_{SERVER_ID}" JSONObject jsonObject = new JSONObject(); jsonObject.put("adminUserId", adminUserDTO.getAdminUserId()); jsonObject.put("uin", uin); jsonObject.put("userName", userName); //jsonObject.put("chatRoomName", chatRoomName); //jsonObject.put("queueName", receiveQueueName); jmsTemplate.send(queueName, jsonObject); ``` > 处理成功后 > > A、获取好友,会向topic.modcontact推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)] > > B、获取群成员,则向receiveQueueName中推送结果。 <br> ### **搜索好友** * 请求队列:queue.searchContact_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | json | <code>JSONObject</code> | 队列传输参数类型 | true | [json.adminUserId] | <code>Long</code> | 平台账号ID | true | [json.uin] | <code>String</code> | 微信号uin | true | [json.userName] | <code>String</code> | 需要搜索的微信号/QQ号/手机号(微信号不能是wxid_xxx开头的) | true | [json.queueName] | <code>String</code> | 接收结果的队列名称(搜索完毕后会将结果推送至该队列) | true * Example ``` queueName = "queue.searchContact_{SERVER_ID}" JSONObject jsonObject = new JSONObject(); jsonObject.put("adminUserId", xxx); jsonObject.put("uin", uin); jsonObject.put("userName", userName); jsonObject.put("queueName", QueueManager.getValue("receiveSearchContact")); jmsTemplate.send(queueName, jsonObject); ``` > 处理成功后会向[json.queueName]推送一条处理结果。 * Response example: ``` { //请求参数会原封不动返回 "adminUserId":xxx, "uin":"xxx", "userName":"xxx", "queueName":"xxxx", //搜索结果如下 "status": 0,//状态码,0表示成功,其他表示失败 "message": "",//错误信息 "user_name": "",//V1 "stranger": "",//V2 "nick_name": "",//昵称 "small_head": "",//头像 "quan_pin": ""//拼音 } ``` <br> ### **添加好友** * 请求队列:queue.addContact_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | json | <code>JSONObject</code> | 队列传输参数类型 | true | [json.adminUserId] | <code>Long</code> | 平台账号ID | true | [json.uin] | <code>String</code> | 微信号uin | true | [json.userName] | <code>String</code> | 需要添加的微信号/QQ号/手机号(微信号不能是wxid_xxx开头的) | true | [json.v1] | <code>String</code> | 搜索微信号返回结果中的V1 | true | [json.v2] | <code>String</code> | 搜索微信号返回结果中的V2 | true | [json.verify] | <code>String</code> | 验证消息(打招呼内容) | true | [json.type] | <code>int</code> | 添加类型<br>1QQ<br>2邮箱<br>3微信号<br>14群聊<br>15手机号<br>18附近的人<br>25漂流瓶<br>29摇一摇<br>30二维码 | true | [json.queueName] | <code>String</code> | 接收结果的队列名称(处理结果将推送至该队列) | true **Example** ``` queueName = "queue.addContact_{SERVER_ID}" JSONObject jsonObject = new JSONObject(); jsonObject.put("adminUserId", adminUserDTO.getAdminUserId()); jsonObject.put("uin", uin); jsonObject.put("userName", userName); jsonObject.put("v1", v1); jsonObject.put("v2", v2); jsonObject.put("verify", verify); jsonObject.put("type", type); jsonObject.put("queueName", QueueManager.getValue("receiveAddContact")); jmsTemplate.send(queueName, jsonObject); ``` 处理成功后会向[json.queueName]推送一条处理结果。 response example: ``` { //请求参数会原封不动返回 "adminUserId":xxx, "uin":"xxx", "userName":"xxx", "v1":"xxxx", "v2":"xxxx", "verify":"xxxx", "type":"xxxx", "queueName":"xxxx", //添加结果如下 "status": 0,//状态码,0表示成功,其他表示失败 "message": "",//错误信息 } ``` <br> ### **通过好友请求** * 请求队列:queue.addNew_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | map | <code>Map</code> | 队列传输参数类型 | true | [map.loginer] | <code>Long</code> | 平台账号ID | true | [map.uin] | <code>String</code> | 微信号uin | true | [map.userName] | <code>String</code> | recommendInfo中的参数为UserName的v1开头的加密字段 | true | [map.opcode] | <code>String</code> | 固定填3 | true | [map.verifyUserTicket] | <code>String</code> | recommendInfo中的参数为Ticket中v2开头的加密字段 | true | [map.verifyContent] | <code>String</code> | 填"" | true | [map.type] | <code>int</code> | xml中的scene<br>添加类型<br>1QQ<br>2邮箱<br>3微信号<br>14群聊<br>15手机号<br>18附近的人<br>25漂流瓶<br>29摇一摇<br>30二维码 | true | [json.wechatUser] | <code>String</code> | 微信号信息json字符串 | web协议必填 * Example ``` <msg fromusername="wxid_63ibkhndjl7i21" encryptusername="v1_b164fe39f73761f1bc04e818df345253cfce2effa72ae9d36074ed4502602225319830f98279b47e2e11509f14b871f6@stranger" fromnickname="合法人類。" content="我是合法人類。" fullpy="hefarenlei" shortpy="HFRL" imagestatus="3" scene="30" country="CN" province="Fujian" city="Xiamen" sign="" percard="1" sex="2" alias="c752184" weibo="" albumflag="0" albumstyle="0" albumbgimgid="" snsflag="17" snsbgimgid="http://shmmsns.qpic.cn/mmsns/jJSbu4Te5ibibue2PRXqlEAVEC0sHHzG4o6W1U0nQSibnnlBicQcjjCv3WZFMWLl2AibCvEsDepdWGqA/0" snsbgobjectid="12784451061011583048" mhash="6d5533cadef8b74eb13b8aa623880570" mfullhash="6d5533cadef8b74eb13b8aa623880570" bigheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/icbJ1Wiavd2eIpVB4O68OECEzx2QG7ZziaWCgUicdbHNwQQaeib7LU5IVXk3iajdy0ePQESVSQ66yVkQ5j10tCrRDPyJM2dXlx40f6BASALPPtgKk/0" smallheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/icbJ1Wiavd2eIpVB4O68OECEzx2QG7ZziaWCgUicdbHNwQQaeib7LU5IVXk3iajdy0ePQESVSQ66yVkQ5j10tCrRDPyJM2dXlx40f6BASALPPtgKk/132" ticket="v2_0e2e4a9a7aa9d162d9580ab57d42dc39e8d155a3fa8afd4e022ed72ebc43b0d3e7973927229c25db79c70bb0d8d2130d79ead73bba642762b8606d0228841842@stranger" opcode="2" googlecontact="" qrticket="" chatroomusername="" sourceusername="" sourcenickname=""> <brandlist count="0" ver="671660875"/> </msg> ``` ``` queueName = "queue.addNew_{SERVER_ID}_{CHILD_ID}" Map<String, Object> arg2 = new HashMap<>(16); arg2.put("loginer", adminUserDTO.getAdminUserId()); arg2.put("uin", contact.getUin()); arg2.put("userName", contact.getContactUserName()); arg2.put("opcode", 3); arg2.put("wechatUser", JSONUtil.toJson(wechatUser)); arg2.put("verifyContent", ""); arg2.put("verifyUserTicket", contact.getVerifyUserTicket()); arg2.put("type", 30); jmsTemplate.send(queueName, arg2); ``` > 处理成功后会向topic.modcontact推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)],根据结果组装成rediskey去获取好友信息。 * response example: ``` { //添加结果如下 "uin": xxx,//所属微信号uin "userName": "",//所属微信号 "field": "",//好友wxid } ``` <br> ### **同步联系人** * 请求队列:queue.syncContact_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | json | <code>JSONObject</code> | 队列传输参数类型 | true | [json.loginer] | <code>Long</code> | 平台账号ID | true | [json.uin] | <code>String</code> | 微信号uin | true * Example ``` queueName = "queue.syncContact_{SERVER_ID}" JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); jsonObject.put("loginer", xxx); jsonObject.put("uin", "xxx"); jmsTemplate.send(queueName, jsonObject); ``` > 处理成功后会向topic.getcontact推送一条处理结果,具体参考[TOPIC-PRODUCTER(API生产)],根据结果组装成rediskey去获取好友信息。 * response example: redisKey: ``` 格式:uin+":wechatContact:"+userName 例子:1150109773:wechatContact:wxid_az12gf9ugnoh22 备注:uin为腾讯官方每个微信的唯一标识;userName为wxid_开头的微信号 ``` redisValue(联系人数据) ``` { "wxid_8fseov8qf5di22":{ "ContactType": "", "ExtInfoExt": "", "Sex": 0, "EncryptUsername": "", "wechatUserName": "wxid_az12gf9ugnoh22", "PYQuanPin": "Nicoleniconi", "Remark": "淑萍", "LabelLists": "", "ChatroomVersion": 0, "ExtInfo": "", "ChatRoomOwner": "", "VerifyFlag": 0, "ContactFlag": 3, "UserName": "wxid_8fseov8qf5di22", "HeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132", "RemarkPYInitial": "SP", "MsgType": 2, "City": "", "NickName": "Nicole_nico'ni", "Province": "", "Alias": "", "Signature": "", "RemarkName": "淑萍", "RemarkPYQuanPin": "shuping", "Uin": 0, "SmallHeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132", "PYInitial": "NICOLENICONI", "Seq": "wxid_8fseov8qf5di22", "BigHeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132" }, ...... } ``` <br> ### **修改备注名** * 请求队列:queue.modifyName_{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | msg | <code>Map</code> | 队列传输参数类型 | true | [msg.loginer] | <code>Long</code> | 平台账号ID | true | [msg.uin] | <code>String</code> | 微信号uin | true | [msg.userName] | <code>String</code> | 需要修改的好友微信号 | true | [msg.newRemarkName] | <code>String</code> | 备注名 | true | [msg.wechatUser] | <code>String</code> | 微信号信息json字符串 | true * Example ``` queueName = "queue.modifyName_{SERVER_ID}_{CHILD_ID}" Map<String, Object> arg1 = new HashMap<>(16); arg1.put("uin", uin); arg1.put("userName", wechatContact.getUserName()); arg1.put("loginer", loginer); arg1.put("newRemarkName", remarkName); arg1.put("wechatUser", JSONUtil.toJson(user)); jmsTemplate.send(queueName, arg1); ``` > 处理成功后会向topic.modifycontact,具体参考[TOPIC-PRODUCTER(API生产)],根据结果组装成rediskey去获取好友信息。 * response example: <br> ### **添加群成员为好友** * 请求队列:queue.addChatRoomContact{SERVER_ID}_{CHILD_ID} * 请求参数: | Param | Type | Description | Required | --- | --- | --- | --- | | json | <code>JSONObject</code> | 队列传输参数类型 | true | [json.loginer] | <code>Long</code> | 平台账号ID | true | [json.uin] | <code>String</code> | 微信号uin | true | [json.userName] | <code>String</code> | 需要添加的群成员微信号 | true | [json.chatRoomName] | <code>String</code> | 群微信号 | true | [json.verify] | <code>String</code> | 验证消息 | true | [json.queueName] | <code>String</code> | 接收返回值的队列 | true * Example ``` queueName = "queue.addChatRoomContact{SERVER_ID}_{CHILD_ID}" JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); jsonObject.put("loginer", xxx); jsonObject.put("uin", "xxx"); jsonObject.put("userName", "xxx"); jsonObject.put("chatRoomName", "xxx"); jsonObject.put("verify", "xxx"); jsonObject.put("queueName", "xxx"); jmsTemplate.send(queueName, jsonObject); ``` > 处理成功后会向topic.modifycontact,具体参考[TOPIC-PRODUCTER(API生产)],根据结果组装成rediskey去获取好友信息。 * response example: ``` //jsonObject为接收到的参数(返回时会全部返回) jsonObject.put("status", 0); jsonObject.put("message", "xxx"); jmsTemplate.send(jsonObject.getString("queueName"), jsonObject.toString); ``` <br> ## **联系人模块消息下发订阅队列** ### **获取联系人** * 推送队列:topic.getcontact > 登录初始化/用户同步好友时推送该topic,根据mqType判断.消费消息后根据字段组装redis的key去获取相应的内容 ``` { "uin": "xxxxxx", "userName": "xxxxxxxxx", "loginer": "18", "field": "xxxxxxxx", "mqType": 7, "source": "ipad" } ``` ### **联系人变更** * 推送队列:topic.modcontact > 好友信息变动会推送该topic ``` { "uin": "xxxxxx",//微信号uin "userName": "xxxxxxxxx",//微信号wxid "loginer": "18", "field": "xxxxxxxx",//好友wxid "mqType": 3, "source": "ipad" } ``` ### **删除好友** * 推送队列:topic.delcontact > 被删除或者其他会推送该topic ``` { "uin": "xxxxxx",//微信号uin "userName": "xxxxxxxxx",//微信号wxid "loginer": "18", "field": "xxxxxxxx",//好友wxid "mqType": 4, "source": "ipad" } ``` ### 获取群 *推送队列:topic.chatroommember > 获取群详细信息/群信息变动会推送该topic ``` { "uin": "xxxxxx",//微信号uin "userName": "xxxxxxxxx",//微信号wxid "loginer": "18", "field": "xxxxxxxx@chatroom",//好友wxid "mqType": 5, "source": "ipad" } ``` ### 群成员变量 * 推送队列:topic.modchatroommember > 预留topic,暂未使用 ``` { "uin": "xxxxxx",//微信号uin "userName": "xxxxxxxxx",//微信号wxid "loginer": "18", "field": "xxxxxxxx@chatroom",//好友wxid "mqType": 5, "source": "ipad" } ```