《微信机器人开发必备:微信Web协议大全(4)》要点:
本文介绍了微信机器人开发必备:微信Web协议大全(4),希望对您有用。如果有疑问,可以联系我们。
相关主题:web微信和微信机器人
https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmedia?sender=@@aa4d90eee1984452cfacf8b510ce6547af58aa4fe34fe567787c716fd262d42c&mediaid=@crypt_3d1bb9c7_7f07116cc9b86e9d8237ad938293eee8a820acfa35e7bdaa41a03fc2fb17b60a4c6da7f967714259dec587505a1b55b10e61e301f733ec718167d8d355f8809257d3fbf382d775e2872e552957e894d52060d8766133214a58ea017e6416216c9f6f1d6056e5b22fe6c78a50efcf384969a7e1b96f348f581853b41be070c16ea4d510b8d10d747a3fc5a3909e1ed2deea43aa6db558c6dd58d453e8d6235d9f6a7c7bc0eb752fb5aee59568ab8de8ff38e0064b827765ae847d6a3503fba9a970006d18f0092a12811ccaec57c071bd&filename=51CTO%E4%B8%8B%E8%BD%BD-MySQL%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98%E4%B8%8E%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1.pdf&fromuser=1443149207&pass_ticket=td%252BZEx1ANBEB8wz%252BxjYhotl3fChIto%252FyC4w%252FNHMopoqOP8Eya9%252FivEs2lsPEDqEj&webwx_data_ticket=gSc8PoV98Y4y98pOsP6hmcpj
sender 发送者UserName
mediaid 媒体id
filename 文件名
fromuser 接受者UserName
pass_ticket 登录返回信息中
webwx_data_ticket cookie中信息
个人账号 以@开头, 例如: @xxx
群聊 以@@开头, 例如: @@xxx
公众号/服务号 以@开头, 但其VerifyFlag & 8 != 0
VerifyFlag:
一般公众号/服务号:8
微信自家的服务号:24
微信官方账号微信团队:56
特殊账号 有特殊的ID(文件传输助手之类)
filehelper, newsapp, fmessage, weibo, qqmail, fmessage, tmessage, qmessage, qqsync,floatbottle, lbsapp, shakeapp, medianote, qqfriend, readerapp, blogapp, facebookapp,masssendapp, meishiapp, feedsapp, voip, blogappweixin, weixin, brandsessionholder,weixinreminder, officialaccounts, notification_messages, wxitil, userexperience_alarm,notification_messages
{
"FromUserName":"",
"ToUserName":"",
"Content":"",
"StatusNotifyUserName":"",
"ImgWidth":0,
"PlayLength":0,
"RecommendInfo":{...},
"StatusNotifyCode":4,
"NewMsgId":"",
"Status":3,
"VoiceLength":0,
"ForwardFlag":0,
"AppMsgType":0,
"Ticket":"",
"AppInfo":{...},
"Url":"",
"ImgStatus":1,
"MsgType":1,
"ImgHeight":0,
"MediaId":"",
"MsgId":"",
"FileName":"",
"HasProductId":0,
"FileSize":"",
"CreateTime":1454602196,
"SubMsgType":0
}
MsgType:
1文本消息
3图片消息
34语音消息
37 VERIFYMSG 好友验证消息
40 POSSIBLEFRIEND_MSG
42共享名片
43视频通话消息
47动画表情
48位置消息
49分享链接
50 VOIPMSG
51微信初始化消息
52 VOIPNOTIFY
53 VOIPINVITE
62小视频
9999 SYSNOTICE
10000系统消息
10002撤回消息
3.9.2 微信初始化消息
MsgType:51
FromUserName:自己ID
ToUserName:自己ID
StatusNotifyUserName:最近联系的联系人ID
Content:
<msg>
<op id='4'>
<username>
// 最近联系的联系人
filehelper,xxx@chatroom,wxid_xxx,xxx,...
</username>
<unreadchatlist>
<chat>
<username>
// 朋友圈
MomentsUnreadMsgStatus
</username>
<lastreadtime>
1454502365
</lastreadtime>
</chat>
</unreadchatlist>
<unreadfunctionlist>
// 未读的功能账号消息, 群发助手, 漂流瓶等
</unreadfunctionlist>
</op>
</msg>
MsgType:1
FromUserName:发送方ID
ToUserName:接收方ID
Content:消息内容
图片消息
MsgType:3
FromUserName:发送方ID
ToUserName:接收方ID
MsgId:用于获取图片
Content:
<msg>
<img length="6503" hdlength="0"/>
<commenturl></commenturl>
</msg>
3.9.4 小视频消息
MsgType:62
FromUserName:发送方ID
ToUserName:接收方ID
MsgId:用于获取小视频
Content:
<msg>
<img length="6503" hdlength="0"/>
<commenturl></commenturl>
</msg>
3.9.5 地理位置消息
MsgType:1
FromUserName:发送方ID
ToUserName:接收方ID
Content: http://weixin.qq.com/cgi-bin/redirectforward?args=xxx
// 属于文本消息, 只不过内容是一个跳转到地图的链接
3.9.6 名片消息
MsgType:42
FromUserName:发送方ID
ToUserName:接收方ID
Content:
<?xml version="1.0"?>
<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=""/>
RecommendInfo:
{
"UserName":"xxx",// ID
"Province":"xxx",
"City":"xxx",
"Scene":17,
"QQNum":0,
"Content":"",
"Alias":"xxx",// 微信号
"OpCode":0,
"Signature":"",
"Ticket":"",
"Sex":0,// 1:男, 2:女
"NickName":"xxx",// 昵称
"AttrStatus":4293221,
"VerifyFlag":0
}
3.9.7 语音消息
MsgType:34
FromUserName:发送方ID
ToUserName:接收方ID
MsgId:用于获取语音
Content:
<msg>
<voicemsg endflag="1" cancelflag="0" forwardflag="0" voiceformat="4" voicelength="1580"length="2026" bufid="216825389722501519"clientmsgid="49efec63a9774a65a932a4e5fcd4e923filehelper174_1454602489" fromusername=""/>
</msg>
3.9.8 动画表情
MsgType:47
FromUserName:发送方ID
ToUserName:接收方ID
Content:
<msg>
<emoji fromusername ="" tousername ="" type="2"
idbuffer="media:0_0" md5="e68363487d8f0519c4e1047de403b2e7"
len ="86235"
productid="com.tencent.xin.emoticon.bilibili"
androidmd5="e68363487d8f0519c4e1047de403b2e7"
androidlen="86235"
s60v3md5 ="e68363487d8f0519c4e1047de403b2e7"
s60v3len="86235"
s60v5md5 ="e68363487d8f0519c4e1047de403b2e7" s60v5len="86235"
cdnurl="http://emoji.qpic.cn/wx_emoji/eFygWtxcoMF8M0oCCsksMA0gplXAFQNpiaqsmOicbXl1OC4Tyx18SGsQ/"
designerid =""
thumburl="http://mmbiz.qpic.cn/mmemoticon/dx4Y70y9XctRJf6tKsy7FwWosxd4DAtItSfhKS0Czr56A70p8U5O8g/0"
encrypturl="http://emoji.qpic.cn/wx_emoji/UyYVK8GMlq5VnJ56a4GkKHAiaC266Y0me0KtW6JN2FAZcXiaFKccRevA/"
aeskey="a911cc2ec96ddb781b5ca85d24143642">
</emoji>
<gameext type="0" content="0"></gameext>
</msg>
3.9.9 普通链接或应用分享消息
MsgType:49
AppMsgType:5
FromUserName:发送方ID
ToUserName:接收方ID
Url:链接地址
FileName:链接标题
Content:
<msg>
<appmsg appid="" sdkver="0">
<title></title>
<des></des>
<type>5</type>
<content></content>
<url></url>
<thumburl></thumburl>
...
</appmsg>
<appinfo>
<version></version>
<appname></appname>
</appinfo>
</msg>
3.9.10 音乐链接消息
MsgType:49
AppMsgType:3
FromUserName:发送方ID
ToUserName:接收方ID
Url:链接地址
FileName:音乐名
AppInfo:// 分享链接的应用
{
Type:0,
AppID: wx485a97c844086dc9
}
Content:
<msg>
<appmsg appid="wx485a97c844086dc9" sdkver="0">
<title></title>
<des></des>
<action></action>
<type>3</type>
<showtype>0</showtype>
<mediatagname></mediatagname>
<messageext></messageext>
<messageaction></messageaction>
<content></content>
<contentattr>0</contentattr>
<url></url>
<lowurl></lowurl>
<dataurl>
http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&guid=ffffffffc104ea2964a111cf3ff3edaf&fromtag=46
</dataurl>
<lowdataurl>
http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&guid=ffffffffc104ea2964a111cf3ff3edaf&fromtag=46
</lowdataurl>
<appattach>
<totallen>0</totallen>
<attachid></attachid>
<emoticonmd5></emoticonmd5>
<fileext></fileext>
</appattach>
<extinfo></extinfo>
<sourceusername></sourceusername>
<sourcedisplayname></sourcedisplayname>
<commenturl></commenturl>
<thumburl>
http://imgcache.qq.com/music/photo/album/63/180_albumpic_143163_0.jpg
</thumburl>
<md5></md5>
</appmsg>
<fromusername></fromusername>
<scene>0</scene>
<appinfo>
<version>29</version>
<appname>摇一摇搜歌</appname>
</appinfo>
<commenturl></commenturl>
</msg>
3.9.11 群消息
MsgType:1
FromUserName:@@xxx
ToUserName:@xxx
Content:
@xxx:<br/>xxx
3.9.12 红包消息
MsgType:49
AppMsgType:2001
FromUserName:发送方ID
ToUserName:接收方ID
Content:未知
网页版(目前走的是系统消息)
MsgType:10000
FromUserName:发送方ID
ToUserName:自己ID
Content:
"你已添加了 xxx , 现在可以开始聊天了。"
"如果陌生人主动添加你为朋友, 请谨慎核实对方身份。"
"收到红包, 请在手机上查看"
https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxverifyuser?r=1476779339614&lang=zh_CN&pass_ticket=td%252BZEx1ANBEB8wz%252BxjYhotl3fChIto%252FyC4w%252FNHMopoqOP8Eya9%252FivEs2lsPEDqEj
header Content-Type:application/json;charset=UTF-8
content
添加好友
{
"BaseRequest":{
"Uin":1443149207,
"Sid":"HqU75NIXRJ6qqu8t",
"Skey":"@crypt_d9da2d81_f3a62e80c16e61ad660dffd14e0ef72c",
"DeviceID":"e799452821014375"
},
"Opcode":2,
"VerifyUserListSize":1,
"VerifyUserList":[
{
"Value":"@2cbb226c459cc5203aa991942f41e19820f5ef3ccceb2dece598412f36406d1f","VerifyUserTicket":""
}
],
"VerifyContent":"我是lbbniu.cn",
"SceneListCount":1,
"SceneList":[
33
],
"skey":"@crypt_d9da2d81_f3a62e80c16e61ad660dffd14e0ef72c"
}
- 通过好友验证
{
"BaseRequest":{
"Uin":1443149207,
"Sid":"HqU75NIXRJ6qqu8t",
"Skey":"@crypt_d9da2d81_f3a62e80c16e61ad660dffd14e0ef72c",
"DeviceID":"e606224692711308"
},
"Opcode":3,
"VerifyUserListSize":1,
"VerifyUserList":[
{
"Value":"@2cbb226c459cc5203aa991942f41e19820f5ef3ccceb2dece598412f36406d1f",
"VerifyUserTicket":"v2_9d2e1b01ee6de582a237f6369a6746c84d3a072b48bf36f152c5c947505e871189cafa09748e05bab27caf812a8f3a12d51da3dceda3cab5f52a406ec124a4a9@stranger"
}
],
"VerifyContent":"",
"SceneListCount":1,
"SceneList":[
33
],
"skey":"@crypt_d9da2d81_f3a62e80c16e61ad660dffd14e0ef72c"
}
{
"BaseResponse":{
"Ret":0,
"ErrMsg":""
}
}