Appearance
回调消息释义(原生版)
微信底层的原始消息格式,未经 Eyun 二次分类。适合需要解析微信原生 msgType 的高级场景。
与优化版的区别
- 优化版:Eyun 将消息按语义重新分类(如
60001私聊文本、80001群聊文本),开发者直接按messageType分发即可,推荐使用。 - 原生版:保留微信原始
msgType(如1文本、3图片、49复合类型),需自行判断私聊/群聊、解析子类型。
消息排重
消息可能因登录、重启或网络重放而重复推送。调用方必须做排重处理,建议以 newMsgId 或 timestamp 作为去重依据。
通用字段
| 参数名 | 类型 | 说明 |
|---|---|---|
| wcId | string | 当前微信 ID |
| account | string | 登录账号 |
| messageType | int | 消息大类,见下方速查表 |
| data | object | 消息体 |
| data.fromUser | string | 发送者微信 ID |
| data.fromGroup | string | 来源群号(群消息时有值) |
| data.toUser | string | 接收者微信 ID |
| data.msgId | long | 消息 ID |
| data.newMsgId | long | 新消息 ID(用于排重) |
| data.msgType | int | 微信原生子类型,见下方速查表 |
| data.timestamp | long | 消息时间戳(秒级) |
| data.content | string / XML | 文本消息为 string,图片/视频等为 XML |
| data.self | boolean | 是否为自己发送 |
messageType 速查
| 值 | 含义 |
|---|---|
0 | 好友请求 |
2 | 群名片 |
3 | 个人名片 |
4 | 下线通知 |
5 | 私聊文本 |
6 | 私聊图片 |
7 | 私聊视频 |
8 | 私聊语音 |
9 | 群聊文本 |
10 | 群聊图片 |
11 | 群聊视频 |
12 | 群聊语音 |
13 | 私聊其他类型 |
14 | 群通知(一),需结合 msgType 判断 |
15 | 好友相关通知 |
16 | 群通知(二),群信息变更 |
17 | 删除相关通知 |
msgType 速查
| 值 | 含义 |
|---|---|
47 | 动图表情 |
48 | 地图位置 |
49 | 复合类型(按 content 中 type 区分:5 链接、6 文件、8 表情、19 聊天记录、33/36 小程序、2000 收付款、2001 红包) |
51 | 手机在群聊会话界面 |
10002 | 新成员入群 |
回调示例
私聊文字消息
好友向微信实例发送一条纯文本消息时触发,messageType 为 5。
json
{
"account": "180132123321",
"data": {
"content": "这是一条文本内容",
"fromUser": "wxid_6j310kguyobz22",
"msgId": 1713244061,
"newMsgId": 769189154845429899,
"self": false,
"timestamp": 1619157348,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 5,
"wcId": "wxid_ctqh94e1ahe722"
}群聊文字消息
群内成员发送文本消息时触发,messageType 为 9,含 fromGroup 和 atlist 字段。
json
{
"account": "180132123321",
"data": {
"content": "大家好呀",
"fromGroup": "22135005646@chatroom",
"fromUser": "wxid_6j310kguyobz22",
"msgId": 1713244067,
"atlist": ["wxid_ctqh94e1ahe722"],
"msgSource": "<msgsource>\n\t<silence>0</silence>\n\t<membercount>3</membercount>\n</msgsource>\n",
"newMsgId": 1798994407239534576,
"self": false,
"timestamp": 1619157466,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 9,
"wcId": "wxid_ctqh94e1ahe722"
}私聊图片消息
好友向微信实例发送图片时触发,messageType 为 6,content 为包含 CDN 地址的 XML,img 为 Base64 缩略图。
json
{
"account": "180132123321",
"data": {
"content": "<?xml version=\"1.0\"?>\n<msg>\n\t<img aeskey=\"be0b1aee8937431c9d1a48d9a678a509\" encryver=\"1\" cdnthumbaeskey=\"...\" cdnthumburl=\"...\" cdnthumblength=\"8533\" cdnthumbheight=\"106\" cdnthumbwidth=\"120\" length=\"24880\" cdnbigimgurl=\"...\" hdlength=\"114382\" md5=\"6a3bd872fbdab1a48ae004c703ea68c3\" /> -->\n</msg>\n",
"fromUser": "wxid_6j310kguyobz22",
"img": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAA...",
"msgId": 1713244075,
"newMsgId": 2006476515498498487,
"self": false,
"timestamp": 1619157875,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 6,
"wcId": "wxid_ctqh94e1ahe722"
}群聊图片消息
群内成员发送图片时触发,messageType 为 10,结构与私聊图片相同,多出 fromGroup 字段。
json
{
"account": "180132123321",
"data": {
"content": "<?xml version=\"1.0\"?>\n<msg>\n\t<img aeskey=\"d6e95edb140ebd12297ff19ad1d67407\" encryver=\"1\" cdnthumbaeskey=\"...\" cdnthumburl=\"...\" cdnthumblength=\"12860\" cdnthumbheight=\"85\" cdnthumbwidth=\"120\" length=\"20447\" md5=\"7e36503b882d4c9030ef9a3e157e824e\" /> -->\n</msg>\n",
"fromGroup": "22135005646@chatroom",
"fromUser": "wxid_6j310kguyobz22",
"img": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAA...",
"msgId": 1713244078,
"newMsgId": 3891063893843458673,
"self": false,
"timestamp": 1619158262,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 10,
"wcId": "wxid_ctqh94e1ahe722"
}私聊语音消息
好友向微信实例发送语音时触发,messageType 为 8,含 voiceLength(语音时长)字段。
json
{
"account": "180132123321",
"data": {
"content": "<msg><voicemsg endflag=\"1\" cancelflag=\"0\" forwardflag=\"0\" voiceformat=\"4\" voicelength=\"5320\" length=\"6307\" bufid=\"508882508695339372\" clientmsgid=\"...\" fromusername=\"wxid_6j310kguyobz22\" /> --></msg>",
"fromUser": "wxid_6j310kguyobz22",
"length": 1853,
"msgId": 1713244080,
"newMsgId": 4167247400520123082,
"self": false,
"timestamp": 1619158387,
"toUser": "wxid_ctqh94e1ahe722",
"voiceLength": 1347,
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 8,
"wcId": "wxid_ctqh94e1ahe722"
}群聊语音消息
群内成员发送语音时触发,messageType 为 12,结构与私聊语音相同,多出 fromGroup 字段。
json
{
"account": "180132123321",
"data": {
"content": "<msg><voicemsg endflag=\"1\" cancelflag=\"0\" forwardflag=\"0\" voiceformat=\"4\" voicelength=\"2620\" length=\"4579\" bufid=\"363157141674656141\" clientmsgid=\"...\" fromusername=\"wxid_6j310kguyobz22\" /> --></msg>",
"fromGroup": "22135005646@chatroom",
"fromUser": "wxid_6j310kguyobz22",
"length": 1853,
"msgId": 1713244081,
"newMsgId": 3141305074970351824,
"self": false,
"timestamp": 1619158413,
"toUser": "wxid_ctqh94e1ahe722",
"voiceLength": 1347,
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 12,
"wcId": "wxid_ctqh94e1ahe722"
}私聊视频消息
好友向微信实例发送视频时触发,messageType 为 7,content 为包含视频 CDN 地址的 XML。
json
{
"account": "180132123321",
"data": {
"content": "<?xml version=\"1.0\"?>\n<msg>\n\t<videomsg aeskey=\"fbfe2ae36a9fa4242b9040073f12990b\" cdnthumbaeskey=\"...\" cdnvideourl=\"...\" cdnthumburl=\"...\" length=\"420081\" playlength=\"3\" cdnthumblength=\"6010\" cdnthumbwidth=\"224\" cdnthumbheight=\"398\" fromusername=\"wxid_6j310kguyobz22\" md5=\"2a5a66558e2418747102efd94d3f5c5d\" newmd5=\"da13d0374150fc3a3b4a32218f7e74bd\" isad=\"0\" /> -->\n</msg>\n",
"fromUser": "wxid_6j310kguyobz22",
"msgId": 1713244082,
"newMsgId": 7208315917323315345,
"self": false,
"timestamp": 1619158524,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 7,
"wcId": "wxid_ctqh94e1ahe722"
}群聊视频消息
群内成员发送视频时触发,messageType 为 11,结构与私聊视频相同,多出 fromGroup 字段。
json
{
"account": "180132123321",
"data": {
"content": "<?xml version=\"1.0\"?>\n<msg>\n\t<videomsg aeskey=\"fbfe2ae36a9fa4242b9040073f12990b\" cdnthumbaeskey=\"...\" cdnvideourl=\"...\" cdnthumburl=\"...\" length=\"420081\" playlength=\"3\" cdnthumblength=\"6010\" cdnthumbwidth=\"224\" cdnthumbheight=\"398\" fromusername=\"wxid_6j310kguyobz22\" md5=\"2a5a66558e2418747102efd94d3f5c5d\" newmd5=\"da13d0374150fc3a3b4a32218f7e74bd\" isad=\"0\" /> -->\n</msg>\n",
"fromGroup": "22135005646@chatroom",
"fromUser": "wxid_6j310kguyobz22",
"msgId": 1713244083,
"newMsgId": 8402487445406190928,
"self": false,
"timestamp": 1619158559,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 11,
"wcId": "wxid_ctqh94e1ahe722"
}群变动通知 — 进入群聊会话界面
微信实例在手机端进入某个群聊的会话界面时触发,messageType 为 14,msgType 为 51。
json
{
"account": "180132123321",
"data": {
"content": "<msg>\n<op id='1'>\n<username>22135005646@chatroom</username>\n</op>\n</msg>",
"fromGroup": "22135005646@chatroom",
"fromUser": "wxid_ctqh94e1ahe722",
"msgId": 1713244148,
"msgType": 51,
"newMsgId": 2553690353246346815,
"self": false,
"timestamp": 1619163632,
"toUser": "22135005646@chatroom",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 14,
"wcId": "wxid_ctqh94e1ahe722"
}群变动通知 — 新成员入群
有人被邀请加入群聊时触发,messageType 为 14,msgType 为 10002,content 中的 XML 包含邀请人和被邀请人信息。
json
{
"account": "180132123321",
"data": {
"content": "22135005646@chatroom:\n<sysmsg type=\"sysmsgtemplate\">\n\t<sysmsgtemplate>\n\t\t<content_template type=\"tmpl_type_profile\">\n\t\t\t<plain><![CDATA[]]></plain>\n\t\t\t<template><![CDATA[\"$username$\"邀请\"$names$\"加入了群聊]]></template>\n\t\t\t<link_list>\n\t\t\t\t<link name=\"username\" type=\"link_profile\">...<!-- 邀请人 --></link>\n\t\t\t\t<link name=\"names\" type=\"link_profile\">...<!-- 被邀请人 --></link>\n\t\t\t</link_list>\n\t\t</content_template>\n\t</sysmsgtemplate>\n</sysmsg>\n",
"fromGroup": "22135005646@chatroom",
"fromUser": "22135005646@chatroom",
"msgId": 1713244072,
"msgType": 10002,
"newMsgId": 7593976597206975100,
"self": false,
"timestamp": 1619157669,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 14,
"wcId": "wxid_ctqh94e1ahe722"
}群变动通知 — 移出群成员
群主将某成员移出群聊时触发,messageType 为 14,msgType 为 10002,content 中的 XML 包含被移除人信息。
json
{
"account": "180132123321",
"data": {
"content": "22135005646@chatroom:\n<sysmsg type=\"sysmsgtemplate\">\n\t<sysmsgtemplate>\n\t\t<content_template type=\"tmpl_type_profile\">\n\t\t\t<plain><![CDATA[]]></plain>\n\t\t\t<template><![CDATA[你将\"$kickoutname$\"移出了群聊]]></template>\n\t\t\t<link_list>\n\t\t\t\t<link name=\"kickoutname\" type=\"link_profile\">...<!-- 被移除人 --></link>\n\t\t\t</link_list>\n\t\t</content_template>\n\t</sysmsgtemplate>\n</sysmsg>\n",
"fromGroup": "22135005646@chatroom",
"fromUser": "22135005646@chatroom",
"msgId": 1713244198,
"msgType": 10002,
"newMsgId": 3647920854016870042,
"self": false,
"timestamp": 1619164448,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 14,
"wcId": "wxid_ctqh94e1ahe722"
}群变动通知 — 群信息变更
群成员入群或退出导致群信息发生变更时触发,messageType 为 16,data 中不含 content,改为群元数据字段。
json
{
"account": "180132123321",
"data": {
"addContactScene": 0,
"bitMask": 4294967295,
"chatRoomNotify": 1,
"chatRoomOwner": "wxid_6j310kguyobz22",
"chatRoomStatus": 3,
"description": "...",
"smallHeadImgUrl": "http://wx.qlogo.cn/mmcrhead/.../0",
"userName": "22135005646@chatroom",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 16,
"wcId": "wxid_ctqh94e1ahe722"
}群变动通知 — 修改群名
群成员修改群名称时触发,messageType 为 14,msgType 为 10002,content 中的 XML 包含操作人和新群名。
json
{
"account": "180132123321",
"data": {
"content": "22135005646@chatroom:\n<sysmsg type=\"sysmsgtemplate\">\n\t<sysmsgtemplate>\n\t\t<content_template type=\"tmpl_type_profile\">\n\t\t\t<plain><![CDATA[]]></plain>\n\t\t\t<template><![CDATA[\"$username$\"修改群名为\"$remark$\"]]></template>\n\t\t\t<link_list>\n\t\t\t\t<link name=\"username\" type=\"link_profile\">...<!-- 操作人 --></link>\n\t\t\t\t<link name=\"remark\" type=\"link_profile\">...<!-- 新群名 --></link>\n\t\t\t</link_list>\n\t\t</content_template>\n\t</sysmsgtemplate>\n</sysmsg>\n",
"fromGroup": "22135005646@chatroom",
"fromUser": "22135005646@chatroom",
"msgId": 1713244204,
"msgType": 10002,
"newMsgId": 273885679441375819,
"self": false,
"timestamp": 1619164507,
"toUser": "wxid_ctqh94e1ahe722",
"wId": "0768a034-4292-4cf6-bd85-379312eb9dc1"
},
"messageType": 14,
"wcId": "wxid_ctqh94e1ahe722"
}离线消息(下线通知)
微信实例下线时触发,messageType 为 4,data 中仅含 wId。
json
{
"account": "18351837032",
"data": {
"wId": "9d9db97b-1e3e-41de-816a-69321a6cee16"
},
"messageType": 4,
"wcId": "wxid_fj9ghhitl4qm22"
}