易创云论坛

 找回密码
 立即注册
查看: 3273|回复: 0

[原创] 微信消息内容

[复制链接]

170

主题

178

帖子

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
100700
发表于 2019-2-6 12:57:56 | 显示全部楼层 |阅读模式
微信一般消息内容
{
    "FromUserName": "",
    "ToUserName": "",
    "Content": "",
    "StatusNotifyUserName": "",
    "ImgWidth": 0,
    "PlayLength": 0,
    "RecommendInfo": {},
    "StatusNotifyCode": 0,
    "NewMsgId": "",
    "Status": 0,
    "VoiceLength": 0,
    "ForwardFlag": 0,
    "AppMsgType": 0,
    "Ticket": "",
    "AppInfo": {},
    "Url": "",
    "ImgStatus": 0,
    "MsgType": 0,
    "ImgHeight": 0,
    "MediaId": "",
    "MsgId": "",
    "FileName": "",
    "HasProductId": 0,
    "FileSize": "",
    "CreateTime": 0,
    "SubMsgType": 0
}

微信回复的所有消息都遵循这一格式,下面将就每种消息类型具体分析。

消息的具体内容微信初始化消息
  1. MsgType: 51
  2. FromUserName: 自己ID
  3. ToUserName: 自己ID
  4. StatusNotifyUserName: 最近联系的联系人ID
  5. Content:
  6.     <msg>
  7.         <op id='4'>
  8.             <username>
  9.                 # 最近联系的联系人
  10.                 filehelper,xxx@chatroom,wxid_xxx,xxx,...
  11.             </username>
  12.             <unreadchatlist>
  13.                 <chat>
  14.                     <username>
  15.                     # 朋友圈
  16.                         MomentsUnreadMsgStatus
  17.                     </username>
  18.                     <lastreadtime>
  19.                         1454502365
  20.                     </lastreadtime>
  21.                 </chat>
  22.             </unreadchatlist>
  23.             <unreadfunctionlist>
  24.             # 未读的功能账号消息,群发助手,漂流瓶等
  25.             </unreadfunctionlist>
  26.         </op>
  27.     </msg>
复制代码
文本消息
  1. MsgType: 1
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. Content: 消息内容
复制代码
图片消息
  1. MsgType: 3
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. MsgId: 用于获取图片
  5. Content:
  6.     <msg>
  7.         <img length="6503" hdlength="0" />
  8.         <commenturl></commenturl>
  9.     </msg>
复制代码

itchat添加了Text键,键值为下载该图片的方法。

[color=rgba(0, 0, 0, 0.75)]小视频消息
  1. MsgType: 62
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. MsgId: 用于获取小视频
  5. Content:
  6.     <msg>
  7.         <img length="6503" hdlength="0" />
  8.         <commenturl></commenturl>
  9.     </msg>
复制代码

itchat添加了Text键,键值为下载该视频的方法。

[color=rgba(0, 0, 0, 0.75)]地理位置消息
  1. MsgType: 1
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. Content: http://weixin.qq.com/cgi-bin/redirectforward?args=xxx
复制代码
itchat添加了Text键,键值为该地点的文本形式。
名片消息
  1. MsgType: 42
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. Content:
  5.     <?xml version="1.0"?>
  6.     <msg bigheadimgurl="" smallheadimgurl="" username="" nickname=""  shortpy="" alias="" imagestatus="3" scene="17" province="" city="" sign="" sex="1" certflag="0" certinfo="" brandIconUrl="" brandHomeUrl="" brandSubscriptConfigUrl="" brandFlags="0" regionCode="" />

  7. RecommendInfo:
  8.     {
  9.         "UserName": "xxx", # ID
  10.         "Province": "xxx",
  11.         "City": "xxx",
  12.         "Scene": 17,
  13.         "QQNum": 0,
  14.         "Content": "",
  15.         "Alias": "xxx", # 微信号
  16.         "OpCode": 0,
  17.         "Signature": "",
  18.         "Ticket": "",
  19.         "Sex": 0, # 1:男, 2:女
  20.         "NickName": "xxx", # 昵称
  21.         "AttrStatus": 4293221,
  22.         "VerifyFlag": 0
  23.     }
复制代码

itchat添加了Text键,键值为该调用add_friend需要的属性。

[color=rgba(0, 0, 0, 0.75)]语音消息
  1. MsgType: 34
  2. FromUserName: 发送方ID
  3. ToUserName: 接收方ID
  4. MsgId: 用于获取语音
  5. Content:
  6.     <msg>
  7.         <voicemsg endflag="1" cancelflag="0" forwardflag="0" voiceformat="4" voicelength="1580" length="2026" bufid="216825389722501519" clientmsgid="49efec63a9774a65a932a4e5fcd4e923filehelper174_1454602489" fromusername="" />
  8.     </msg>
复制代码

tchat添加了Text键,键值为下载该图片表情的方法。

[color=rgba(0, 0, 0, 0.75)]

由于版权问题,部分微信商店提供的表情是无法下载的,注意。

[color=rgba(0, 0, 0, 0.75)]普通链接或应用分享消息
  1. MsgType: 49
  2. AppMsgType: 5
  3. FromUserName: 发送方ID
  4. ToUserName: 接收方ID
  5. Url: 链接地址
  6. FileName: 链接标题
  7. Content:
  8.     <msg>
  9.         <appmsg appid=""  sdkver="0">
  10.             <title></title>
  11.             <des></des>
  12.             <type>5</type>
  13.             <content></content>
  14.             <url></url>
  15.             <thumburl></thumburl>
  16.             ...
  17.         </appmsg>
  18.         <appinfo>
  19.             <version></version>
  20.             <appname></appname>
  21.         </appinfo>
  22.     </msg>
复制代码
音乐链接消息
  1. MsgType: 49
  2. AppMsgType: 3
  3. FromUserName: 发送方ID
  4. ToUserName: 接收方ID
  5. Url: 链接地址
  6. FileName: 音乐名

  7. AppInfo: # 分享链接的应用
  8.     {
  9.         Type: 0,
  10.         AppID: wx485a97c844086dc9
  11.     }

  12. Content:
  13.     <msg>
  14.         <appmsg appid="wx485a97c844086dc9"  sdkver="0">
  15.             <title></title>
  16.             <des></des>
  17.             <action></action>
  18.             <type>3</type>
  19.             <showtype>0</showtype>
  20.             <mediatagname></mediatagname>
  21.             <messageext></messageext>
  22.             <messageaction></messageaction>
  23.             <content></content>
  24.             <contentattr>0</contentattr>
  25.             <url></url>
  26.             <lowurl></lowurl>
  27.             <dataurl>
  28.                 http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&guid=ffffffffc104ea2964a111cf3ff3edaf&fromtag=46
  29.             </dataurl>
  30.             <lowdataurl>
  31.                 http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&guid=ffffffffc104ea2964a111cf3ff3edaf&fromtag=46
  32.             </lowdataurl>
  33.             <appattach>
  34.                 <totallen>0</totallen>
  35.                 <attachid></attachid>
  36.                 <emoticonmd5></emoticonmd5>
  37.                 <fileext></fileext>
  38.             </appattach>
  39.             <extinfo></extinfo>
  40.             <sourceusername></sourceusername>
  41.             <sourcedisplayname></sourcedisplayname>
  42.             <commenturl></commenturl>
  43.             <thumburl>
  44.                 http://imgcache.qq.com/music/photo/album/63/180_albumpic_143163_0.jpg
  45.             </thumburl>
  46.             <md5></md5>
  47.         </appmsg>
  48.         <fromusername></fromusername>
  49.         <scene>0</scene>
  50.         <appinfo>
  51.             <version>29</version>
  52.             <appname>摇一摇搜歌</appname>
  53.         </appinfo>
  54.         <commenturl></commenturl>
  55.     </msg>
复制代码
群消息
  1. MsgType: 1
  2. FromUserName: @@xxx
  3. ToUserName: @xxx
  4. Content:
  5.     @xxx:<br/>xxx
复制代码

itchat增加了三个群聊相关的键值:
* isAt: 判断是否@本号
* ActualNickName: 实际NickName
* Content: 实际Content

[color=rgba(0, 0, 0, 0.75)]红包消息
  1. MsgType: 49
  2. AppMsgType: 2001
  3. FromUserName: 发送方ID
  4. ToUserName: 接收方ID
  5. Content: 未知
复制代码
系统消息
  1. MsgType: 10000
  2. FromUserName: 发送方ID
  3. ToUserName: 自己ID
  4. Content:
  5.     "你已添加了 xxx ,现在可以开始聊天了。"
  6.     "如果陌生人主动添加你为朋友,请谨慎核实对方身份。"
  7.     "收到红包,请在手机上查看"
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|易创云论坛 ( 吉ICP备17001024号-1 )

GMT+8, 2025-2-1 23:01 , Processed in 0.315459 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表