-
Notifications
You must be signed in to change notification settings - Fork 13
Overview
This page aims to provide you with a general understand of how the API works. For details, please refer to the source code.
There are 5 key processes. Since we've decided to close source, only brief introduction will be given.
First, the API fires a GET to jsLoginURL to obtain the "uuid" which will be used to download the QRCode image as well as to login.
After getting the uuid, the API sends another GET request to the following address:
"https://login.weixin.qq.com/qrcode/" + uuid
to download the QR code image. After this, the API sends the same package to:
"https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?tip=1&loginicon=true&uuid=" + System.Net.WebUtility.UrlEncode(uuid)
repeatedly to check whether the QR code has been scanned by the user, which would result in a return code of 201
and, if loginicon
is set to true
, the base64-encoded avatar of the user. If the user doesn't scan the code in 25 seconds, the server returns 408
.
Then, the API continues to send GET requests to the same address with tip
set to 0
, the server returns 200
, together with the redirect URL, if the user click the "Confirm Login" button on the phone.
Once confirmed, the API accesses the redirect URL to get important cookies.
After logging in, the API sends a POST request to:
"https://" + host + "/cgi-bin/mmwebwx-bin/webwxinit"
to get user info and SyncKeys to be used later.
Right after the Init Process, the API accesses:
"https://" + host + "/cgi-bin/mmwebwx-bin/webwxgetcontact"
To get the contact list.
Once triggered, the API starts the SyncCheck Process indefinitely. By accessing
"https://webpush." + host + "/cgi-bin/mmwebwx-bin/synccheck"
, the API determines whether there is new content to be synced. If no, it restarts the SyncCheck Process; if yes, it triggers the Sync Process.
Triggered by SyncCheck Process, the API sends a POST request to:
"https://" + host + "/cgi-bin/mmwebwx-bin/webwxsync
and the result is deserialized into a SyncResponse
object, which is then mapped into a List<Message>
object to be sent as an event argument of the SyncCompleted
event.