Skip to content

回调消息释义(完全版)

Eyun 平台会把微信原生消息二次处理后推送到回调地址。完全版字段更丰富,适合需要区分文本、图片、视频、语音、群通知、好友通知等场景的接入方。

注意

  • 回调事件类型较多,本文档覆盖常见字段和常见类型;未列出的字段可按业务需要自行调试处理。
  • 消息可能因网络重放或历史同步而重复推送,调用方必须做消息排重,优先使用 newMsgId,并结合 timestamp 做兜底。

响应参数

参数名类型说明
wcIdstring当前微信 ID
accountstring开发者账号
messageTypeintEyun 归类后的消息类型
dataobject消息体
data.wIdstring登录实例标识
data.fromUserstring发送者微信 ID
data.fromGroupstring来源群号,群消息时有值
data.toUserstring接收者微信 ID
data.msgIdnumber消息 ID
data.newMsgIdnumber新消息 ID,建议用于排重
data.msgTypeint微信原生消息子类型
data.timestampnumber消息时间戳
data.contentstring消息内容;文本为普通字符串,图片/视频/文件等通常为 XML
data.selfboolean是否为自己发送的消息
data.msgSourcestring消息来源扩展信息,部分群消息存在
data.lengthnumber语音等媒体消息长度字段
data.voiceLengthnumber语音播放时长字段

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 字段继续区分
51手机在群聊会话界面事件
10002群系统通知,例如入群、移出、改群名等

msgType=49 常见子类型

content.type含义
5链接
6文件
8输入法表情
19聊天记录
33 / 36小程序
2000收付款
2001红包

回调示例

私聊文本

json
{
  "account": "180132123321",
  "messageType": 5,
  "wcId": "wxid_ctqh94e1ahe722",
  "data": {
    "wId": "0768a034-4292-4cf6-bd85-379312eb9dc1",
    "content": "这是一条文本内容",
    "fromUser": "wxid_6j310kguyobz22",
    "msgId": 1713244061,
    "newMsgId": 769189154845429899,
    "self": false,
    "timestamp": 1619157348,
    "toUser": "wxid_ctqh94e1ahe722"
  }
}

群聊文本

json
{
  "account": "180132123321",
  "messageType": 9,
  "wcId": "wxid_ctqh94e1ahe722",
  "data": {
    "wId": "0768a034-4292-4cf6-bd85-379312eb9dc1",
    "content": "大家好呀",
    "fromGroup": "22135005646@chatroom",
    "fromUser": "wxid_6j310kguyobz22",
    "msgId": 1713244067,
    "msgSource": "<msgsource><silence>0</silence><membercount>3</membercount></msgsource>",
    "newMsgId": 1798994407239534576,
    "self": false,
    "timestamp": 1619157466,
    "toUser": "wxid_ctqh94e1ahe722"
  }
}

图片消息

json
{
  "account": "180132123321",
  "messageType": 6,
  "wcId": "wxid_ctqh94e1ahe722",
  "data": {
    "wId": "0768a034-4292-4cf6-bd85-379312eb9dc1",
    "content": "<?xml version=\"1.0\"?><msg><img aeskey=\"be0b1aee...\" cdnthumburl=\"3072020100...\" cdnmidimgurl=\"3072020100...\" length=\"24880\" md5=\"6a3bd872fbdab1a48ae004c703ea68c3\" /></msg>",
    "fromUser": "wxid_6j310kguyobz22",
    "msgId": 1713244079,
    "newMsgId": 2838595706480537677,
    "self": false,
    "timestamp": 1619158263,
    "toUser": "wxid_ctqh94e1ahe722"
  }
}

语音消息

json
{
  "account": "180132123321",
  "messageType": 8,
  "wcId": "wxid_ctqh94e1ahe722",
  "data": {
    "wId": "0768a034-4292-4cf6-bd85-379312eb9dc1",
    "content": "<msg><voicemsg voiceformat=\"4\" voicelength=\"5320\" length=\"6307\" bufid=\"508882508695339372\" fromusername=\"wxid_6j310kguyobz22\" /></msg>",
    "fromUser": "wxid_6j310kguyobz22",
    "length": 1853,
    "msgId": 1713244080,
    "newMsgId": 4167247400520123082,
    "self": false,
    "timestamp": 1619158387,
    "toUser": "wxid_ctqh94e1ahe722",
    "voiceLength": 1347
  }
}

使用建议

  • 接入方应先按 messageType 做一级分流,再按 msgType 或 XML 中的 type 做细分。
  • 媒体消息下载时,优先把回调中的 content 原样传给下载接口。
  • 群消息要同时关注 fromGroupfromUser,避免把群成员误判为私聊联系人。