This is a creation in Article, where the information may have evolved or changed.
Main modules
- Get UUID
- Get QR code based on UUID
- Display two-dimensional code
- Scan Code Login
- Initializing information
- Turn on State synchronization notifications
- Get Contacts
- Send Message
- Synchronizing information
- Get Auto Reply content
Source Address
Https://github.com/qianlnk/gobot
Web-Version API
Get UUID
window.QRLogin.code = 200; window.QRLogin.uuid = "xxx";
- Realize
Reference Getuuid method
Get two-dimensional code
Interface Address
https://login.weixin.qq.com/qrcode/{UUID}?t=webwx&_={Timestamp}
Method
GET
Realize
Reference Genqrcode method
Output the QR code to the terminal
Https://github.com/qianlnk/qrcode
Login
- Interface Address
https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip={1,0}&uuid=(UUID}&_={Timestamp}
Tip:1 No sweep code 0 has been swept code
window.code=xxx;xxx: 408 登陆超时 201 扫描成功 200 确认登录当返回200时,还会有window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";
Get the URL that is required by the regular, followed by a unified base_url representation.
BASE_URL = https://wx.qq.com
Skey string `xml:"skey"` Wxsid string `xml:"wxsid"` Wxuin string `xml:"wxuin"` PassTicket string `xml:"pass_ticket"`
Initialization
type InitResult struct { BaseResponse BaseResponse `json:"BaseResponse"` Count int `json:"Count"` ContactList []Contact `json:"ContactList"` SyncKey SyncKey `json:"SyncKey"` User User `json:"User"` ChatSet string `json:"ChatSet"` SKey string `json:"SKey"` ClientVersion int `json:"ClientVersion"` SystemTime int `json:"SystemTime"` GrayScale int `json:"GrayScale"` InviteStartCount int `json:"InviteStartCount"` MPSubscribeMsgCount int `json:"MPSubscribeMsgCount"` MPSubscribeMsgList []MPSubscribeMsg `json:"MPSubscribeMsgList"` ClickReportInterval int `json:"ClickReportInterval"`}
- Realize
Refer to the Init method
Status notifications
params := make(map[string]interface{}) params["BaseRequest"] = w.baseRequest params["Code"] = 3 params["FromUserName"] = w.user.UserName params["ToUserName"] = w.user.UserName params["ClientMsgId"] = int(time.Now().Unix())
-Achieve
Reference Statusnotify method
Get Contacts
params := make(map[string]interface{}) params["BaseRequest"] = w.baseRequest
-Method
POST
- Realize
Reference GetContact method
Synchronizing information
- Interface Address
https://host/cgi-bin/mmwebwx-bin/synccheck
Host
Hosts = []string{ "webpush.wx.qq.com", "webpush2.wx.qq.com", "webpush.wechat.com", "webpush1.wechat.com", "webpush2.wechat.com", "webpush1.wechatapp.com", }
-Parameters
v := url.Values{} v.Add("r", w.timestamp()) v.Add("sid", w.loginRes.Wxsid) v.Add("uin", w.loginRes.Wxuin) v.Add("skey", w.loginRes.Skey) v.Add("deviceid", w.deviceID) v.Add("synckey", w.strSyncKey()) v.Add("_", w.timestamp())
window.synccheck={retcode:"xxx",selector:"xxx"}retcode: 0 正常 1100 手机上退出网页版 1101在其他地方登录网页版selector: 0 正常 2 新的消息 7 进入/离开聊天界面
- Realize
Reference Synccheck method
When selector=2 the new information is read
params := make(map[string]interface{}) params["BaseRequest"] = w.baseRequest params["SyncKey"] = w.syncKey params["rr"] = ^int(time.Now().Unix())
Modify Synckey, important
if msg.BaseResponse.Ret == 0 { w.syncKey = msg.SyncKey }
- Realize
Reference Wxsync method
Send Message
params := make(map[string]interface{}) params["BaseRequest"] = w.baseRequest msg := make(map[string]interface{}) msg["Type"] = 1 msg["Content"] = message msg["FromUserName"] = w.user.UserName msg["ToUserName"] = to msg["LocalID"] = clientMsgID msg["ClientMsgId"] = clientMsgID params["Msg"] = msg
Turing API
Get Auto Reply content
params := make(map[string]interface{}) params["userid"] = uid params["key"] = w.cfg.Tuling.Keys[w.user.NickName].Key params["info"] = msg
Code int `json:"code"` Text string `json:"text"` //100000 URL string `json:"url"` //200000 List interface{} `json:"list"` //302000 []News 308000 []Menu
- Realize
Reference Getreply method
Run.png