1. Open the homepage and assign a random uuid,
2. Get the QR code image based on the uuid.
3. WeChat client scans the picture and confirms login on the client.
4. The browser keeps calling an interface. If the login is successful, it calls the login interface
5. At this time, you can get the contact list and send a message. Then continuously call the synchronization interface.
6. If the synchronization interface returns, you can obtain new messages and then continue to call the synchronization interface.
Source code address: github.com/biezhi/wechat-robot
+--------------+ +---------------+ +---------------+ | | | | | | | Get UUID | | Get Contact | | Status Notify | | | | | | | +-------+------+ +-------^-------+ +-------^-------+ | | | | +-------+ +--------+ | | | +-------v------+ +-----+--+------+ +--------------+ | | | | | | | Get QRCode | | Weixin Init +------> Sync Check <----+ | | | | | | | +-------+------+ +-------^-------+ +-------+------+ | | | | | | | +-----------+ | | | +-------v------+ +-------+--------+ +-------v-------+ | | Confirm Login | | | | +------> Login +---------------> New Login Page | | Weixin Sync | | | | | | | | | +------+-------+ +----------------+ +---------------+ | | |QRCode Scaned| +-------------+
API | Get UUID |
---|---|
url | https ://login.weixin.qq.com/jslogin |
method | GET |
URL Encode | |
appid : wx782c26e4c19acffb fun : new lang : zh_CN _ : Timestamp |
) :window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"
method | |
params | |
t | : webwx_ : Timestamp |
method | |
params | |
: 1: Not scanned 0 : Scanned | uuid : Obtained uuid _ : Timestamp | Return data (String ):
(refer to method login)
method | |
params | |
: xxx | uuid : xxx lang : zh_CN scan : xxx fun : new | Return Data (
<error> <ret>0</ret> <message>OK</message> <skey>xxx</skey> <wxsid>xxx</wxsid> <wxuin>xxx</wxuin> <pass_ticket>xxx</pass_ticket> <isgrayscale>1</isgrayscale></error>
In this step, get the skey,
wxsid, wxuin
, # in xml ##pass_ticket5. WeChat initialization (refer to method wxInit)
url | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
method | POST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
header | Content -Type: application/json; charset=UTF-8|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
params | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sid: xxx, | Skey: xxx, DeviceID: xxx, } } ## 返回数据(JSON): { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "Count": 11, "ContactList": [...], "SyncKey": { "Count": 4, "List": [ { "Key": 1, "Val": 635705559 }, ... ] }, "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": xxx, "ClientVersion": 369297683, "SystemTime": 1453124908, "GrayScale": 1, "InviteStartCount": 40, "MPSubscribeMsgCount": 2, "MPSubscribeMsgList": [...], "ClickReportInterval": 600000 } Copy after login 这一步中获取 6. 开启微信状态通知(参考方法 wxStatusNotify)
返回数据(JSON): { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, ... } Copy after login 7. 获取联系人列表(参考方法 getContact)
返回数据(JSON): { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MemberCount": 334, "MemberList": [ { "Uin": 0, "UserName": xxx, "NickName": "Urinx", "HeadImgUrl": xxx, "ContactFlag": 3, "MemberCount": 0, "MemberList": [], "RemarkName": "", "HideInputBarFlag": 0, "Sex": 0, "Signature": "我是二蛋", "VerifyFlag": 8, "OwnerUin": 0, "PYInitial": "URINX", "PYQuanPin": "Urinx", "RemarkPYInitial": "", "RemarkPYQuanPin": "", "StarFriend": 0, "AppAccountFlag": 0, "Statues": 0, "AttrStatus": 0, "Province": "", "City": "", "Alias": "Urinxs", "SnsFlag": 0, "UniFriend": 0, "DisplayName": "", "ChatRoomId": 0, "KeyWord": "gh_", "EncryChatRoomId": "" }, ... ], "Seq": 0 } Copy after login 8.消息检查(参考方法 syncCheck)
返回数据(String): window.synccheck={retcode:"xxx",selector:"xxx"} retcode: 0 正常 1100 失败/登出微信 selector: 0 正常 2 新的消息 7 进入/离开聊天界面 Copy after login 9. 获取最新消息(参考方法 webwxsync)
返回数据(JSON): { 'BaseResponse': {'ErrMsg': '', 'Ret': 0}, 'SyncKey': { 'Count': 7, 'List': [ {'Val': 636214192, 'Key': 1}, ... ] }, 'ContinueFlag': 0, 'AddMsgCount': 1, 'AddMsgList': [ { 'FromUserName': '', 'PlayLength': 0, 'RecommendInfo': {...}, 'Content': "", 'StatusNotifyUserName': '', 'StatusNotifyCode': 5, 'Status': 3, 'VoiceLength': 0, 'ToUserName': '', 'ForwardFlag': 0, 'AppMsgType': 0, 'AppInfo': {'Type': 0, 'AppID': ''}, 'Url': '', 'ImgStatus': 1, 'MsgType': 51, 'ImgHeight': 0, 'MediaId': '', 'FileName': '', 'FileSize': '', ... }, ... ], 'ModChatRoomMemberCount': 0, 'ModContactList': [], 'DelContactList': [], 'ModChatRoomMemberList': [], 'DelContactCount': 0, ... } Copy after login 10. 发送消息(参考方法 webwxsendmsg)
返回数据(JSON): { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, ... } Copy after login 更多资料: 【相关推荐】 1. 微信公众号源码下载 2. 阿狸子订单系统源码下载 The above is the detailed content of Detailed explanation of WeChat protocol. For more information, please follow other related articles on the PHP Chinese website!
Related labels:
source:php.cn
Previous article:Detailed picture and text explanation of obtaining geographical location on WeChat
Next article:Detailed explanation of books on WeChat development
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
How to display the mobile version of Google Chrome
Hello teacher, how can I change Google Chrome into a mobile version?
From 2024-04-23 00:22:19
0
11
2309
There is no output in the parent window
document.onclick = function(){ window.opener.document.write('I am the output of the child ...
From 2024-04-18 23:52:34
0
1
1820
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|