《微信机器人开发必备:微信Web协议大全》要点:
本文介绍了微信机器人开发必备:微信Web协议大全,希望对您有用。如果有疑问,可以联系我们。
相关主题:web微信和微信机器人
https://login.wx.qq.com/jslogin?appid=wx782c26e4c19acffb&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage&fun=new&lang=zh_CN&_=1476606163580
appid: wx782c26e4c19acffb(固定值)
redirect_rui: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage(url编码)
fun:new(固定值)
lang: zh_CN(固定值)
_: unix时间戳
window.QRLogin.code = 200; window.QRLogin.uuid = "gf5Gk61zEA==";
window.QRLogin.uuid的值就是我们需要的uuid
https://login.weixin.qq.com/qrcode/gf5Gk61zEA==
固定格式: https://login.weixin.qq.com/qrcode/{uuid}
https://login.weixin.qq.com/l/gf5Gk61zEA==
固定格式: https://login.weixin.qq.com/l/{uuid}
https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=gf5Gk61zEA==&tip=0&r=862560455&_=1476606163582
loginicon:true
uuid: uuid
tip:0
r:862560455(非必须)
_: unix时间戳
window.code=408;// 登录超时(408)
window.code=201;window.userAvatar=' userAvatar为用户头像
window.code=200;// 确认登录(200), redirect_uri获取cookie
window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AYfheMIH6tt9EmcZ0DxCKF4a@qrticket_0&uuid=YeGrrvqmHQ==&lang=zh_CN&scan=1476606728";
https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AYfheMIH6tt9EmcZ0DxCKF4a@qrticket_0&uuid=YeGrrvqmHQ==&lang=zh_CN&scan=1476606728&fun=new&version=v2&lang=zh_CN
上一步的redirect_uri
<error>
<ret>0</ret>
<message></message>
<skey>@crypt_14ae1b12_b73ba2673448154847d7007a2de3c53b</skey>
<wxsid>jSsRlGGPyY7U8det</wxsid>
<wxuin>566148615</wxuin>
<pass_ticket>kUY4PSgKNy4eOlWI%2FwIBMVULe3KHPVyvDqw1%2B4DVVu9McVvE2d5fL7LFOfa4iYnk</pass_ticket>
<isgrayscale>1</isgrayscale>
</error>
skey
, wxsid
, wxuin
, pass_ticket
和返回的cookie
都需要保存(后面要用)
获取联系人信息, 公众号信息, 自己的账号信息
https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=862039733&lang=zh_CN&pass_ticket=kUY4PSgKNy4eOlWI%252FwIBMVULe3KHPVyvDqw1%252B4DVVu9McVvE2d5fL7LFOfa4iYnk
header Content-Type:application/json;charset=UTF-8
content
{
"BaseRequest":{
"Uin":"566148615",
"Sid":"jSsRlGGPyY7U8det",
"Skey":"@crypt_14ae1b12_b73ba2673448154847d7007a2de3c53b",
"DeviceID":"e119795675188164"
}
}
Uin,Sid,Skey:登录后获取的xml中的数据
DeviceID: e +随机数
{
"BaseResponse":{
"Ret":0,
"ErrMsg":""
},
"Count":11,
"ContactList":[...],//联系人信息, 公众号信息, 群
"SyncKey":{
"Count":4,
"List":[
{
"Key":1,
"Val":635705559
},
...//同步key值, 下次请求时要写到上
]
},
"User":{
"Uin": xxx,
"UserName": xxx,
"NickName": xxx,
"HeadImgUrl": xxx,
"RemarkName":"",
"PYInitial":"",
"PYQuanPin":"",
"RemarkPYInitial":"",
"RemarkPYQuanPin":"",
"HideInputBarFlag":0,
"StarFriend":0,
"Sex":1,
"Signature":"Apt-get install B",
"AppAccountFlag":0,
"VerifyFlag":0,
"ContactFlag":0,
"WebWxPluginSwitch":0,
"HeadImgFlag":1,
"SnsFlag":17
},
"ChatSet":"xxx",
"SKey":"@crypt_14ae1b12_b73ba2673448154847d7007a2de3c53b",
"ClientVersion":369302288,
"SystemTime":1476608977,
"GrayScale":1,
"InviteStartCount":40,
"MPSubscribeMsgCount":7,
"ClickReportInterval":600000
}
客户端读取消息后要发起请求, 告诉服务器消息已经读取, 从而通知手机客户端
https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?pass_ticket=ZDJfLCa0EAKrLn2CdD7MDl%252B54GwlW0IEiwYOsm6II%252F8W57y0pF1F8fqS%252B5z4INU5
pass_ticket 登录请求返回的xml中的值
header Content-Type:application/json;charset=UTF-8
content
{
"BaseRequest":{
"Uin":566148615,
"Sid":"EKjoZCMRIvrY7NIP",
"Skey":"@crypt_14ae1b12_f59314a579c67b15f838d09feb79c17f",
"DeviceID":"e098855372553243"
},
"Code":3,
"FromUserName":自己ID,
"ToUserName":自己ID,
"ClientMsgId":时间戳
}
{
"BaseResponse":{
"Ret":0,
"ErrMsg":""
},
"MsgID":"1525762281689643050"
}