1. Ouvrez la page d'accueil et attribuez un uuid aléatoire,
2. Obtenez l'image du code QR basée sur l'uuid.
3. Le client WeChat scanne l'image et confirme la connexion sur le client.
4. Le navigateur continue d'appeler une interface. Si la connexion réussit, il appelle l'interface de connexion
5. À ce moment, vous pouvez obtenir la liste de contacts et envoyer des messages. . Appelez ensuite en continu l'interface de synchronisation.
6. Si l'interface de synchronisation revient, vous pouvez recevoir de nouveaux messages puis continuer à appeler l'interface de synchronisation.
Adresse du code source : 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 | Obtenir l'UUID | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
url | https://login.weixin.qq.com/jslogin | ||||||||||
méthode | GET td > | ||||||||||
données | Encodage d'URL | ||||||||||
params | appid strong > : wx782c26e4c19acffb
|
window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"
API | 显示二维码 |
---|---|
url | login.weixin.qq.com/qrcode/{uuid} |
method | POST |
params | t : webwx _ : 时间戳 |
API | 二维码扫描登录 |
---|---|
url | login.weixin.qq.com/cgi-bin/mmwebwx-bin/login |
method | GET |
params | tip : 1:未扫描 0:已扫描 uuid : 获取到的uuid _ : 时间戳 |
3. la méthode waitForLogin) ici Il s'agit de la connexion de confirmation WeChat
API | Scannez le code QR pour vous connecter | tr>
---|---|
url | login.weixin.qq.com/cgi-bin/mmwebwx-bin /login | < /tr>
méthode | GET |
params | Astuce : 1 : Non analysé 0 : Analysé 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"; Copier après la connexion _ : Horodatage |
API | webwxnewloginpage |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage |
method | GET |
params | ticket : xxx uuid : xxx lang : zh_CN scan : xxx fun : new |
Cookie (reportez-vous à la méthode de connexion)
API | webwxnewloginpage |
---|---|
url | < td style="word-break : break-all;">wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage|
méthode | GET | < /tr>
params | ticket : xxx uuid : xxx <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> Copier après la connexion scan : xxx |
API | webwxinit |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxinit |
method | POST |
data | JSON |
header | Content-Type: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx, } } |
API | webwxinit | < /tr>
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/ webwxinit | méthode | POST |
données | JSON<🎜> |
en-tête | Contenu -Type : application/json ; charset=UTF -8 |
params | { <🎜> BaseRequest : { <🎜> Uin : xxx, <🎜 > 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 }
这一步中获取 SyncKey
, User
后面的消息监听用。
API | webwxstatusnotify |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify |
method | POST |
data | JSON |
header | Content-Type: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx }, Code: 3, FromUserName: 自己的ID, ToUserName: 自己的ID, ClientMsgId: 时间戳 } |
返回数据(JSON):
{ "BaseResponse": { "Ret": 0, "ErrMsg": "" }, ... }
API | webwxgetcontact |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact |
method | POST |
data | JSON |
header | ContentType: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx, } } |
返回数据(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 }
API | synccheck |
---|---|
url | webpush2.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck |
method | GET |
data | JSON |
header | ContentType: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx, } } |
返回数据(String):
window.synccheck={retcode:"xxx",selector:"xxx"} retcode: 0 正常 1100 失败/登出微信 selector: 0 正常 2 新的消息 7 进入/离开聊天界面
API | webwxsync |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=xxx&skey=xxx&pass_ticket=xxx |
method | POST |
data | JSON |
header | ContentType: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx }, SyncKey: xxx, rr: 时间戳取反 } |
返回数据(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, ... }
API | webwxsendmsg |
---|---|
url | wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx |
method | POST |
data | JSON |
header | ContentType: application/json; charset=UTF-8 |
params | { BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx }, Msg: { Type: 1 文字消息, Content: 要发送的消息, FromUserName: 自己的ID, ToUserName: 好友的ID, LocalID: 与clientMsgId相同, ClientMsgId: 时间戳左移4位随后补上4位随机数 } } |
返回数据(JSON):
{ "BaseResponse": { "Ret": 0, "ErrMsg": "" }, ... }
更多资料:
github.com/xiangzhai/qwx
github.com/Urinx/WeixinBot
www.07net01.com/2016/01/1201188.html
www.cnblogs.com/xiaozhi_5638/p/4923811.html
【相关推荐】
1. 微信公众号源码下载
2. 阿狸子订单系统源码下载
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!