# wechat **Repository Path**: a9991/wechat ## Basic Information - **Project Name**: wechat - **Description**: 微信机器人 优化登录 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-30 - **Last Updated**: 2025-09-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 微信自动聊天机器人 新注册微信可登录 ## 登录流程 auth.png ### 1.获取UUID `jslogin` 接口地址:`https://login.wx.qq.com/jslogin` 请求方式:GET 请求参数: | 参数 | 类型 | 参考值 | 说明 | |--------------|--------|-----------------------------------------------------------|------------| | appid | string | wx782c26e4c19acffb | 固定值 | | redirect_uri | string | `https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage` | 固定值 | | fun | string | new | 固定值 | | lang | string | zh_CN | 固定值 | | _ | int | 1714469702208 | 获取13位毫秒时间戳 | 返回值: ``` window.QRLogin.code = 200; window.QRLogin.uuid = "4eAbCxhPEQ=="; ``` ---- ### 2.获取二维码 `qrcode` 接口地址:`https://login.wx.qq.com/qrcode/替换为uuid` 请求方式:GET 返回值: --- ### 3.监听登录状态 `mmwebwx-bin/login` 接口地址:`https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login` 请求方式:GET 请求参数: | 参数 | 类型 | 参考值 | 说明 | |-----------|--------|:--------------|:---------------------| | loginicon | bool | true | 固定值 | | uuid | string | oeDKxJwoqw== | 在`jslogin`中获取 | | tip | int | 1 | 固定值 | | r | int32 | -777751365 | 是取`_`中的int64转32位然后取反 | | _ | int64 | 1714469702208 | 获取13位毫秒时间戳 | 返回值: ``` #一般请求 window.code=408; #下面是成功 会多返回一个 redirect_uri window.code = 200; window.redirect_uri = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AdbZxwhwQxDLnsAuzR@qrticket_0&uuid=Id8BhmDjUg==&lang=zh_CN&scan=1715067458"; ``` 参数说明: | Code | 说明 | |------|------------| | 408 | 请扫描 | | 400 | 二维码已过期 | | 201 | 手机端已扫码,待确认 | | 200 | 已确认登录 | ---- ### 4.获取基础信息 `mmwebwx-bin/webwxnewloginpage` 请求连接:`https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage` 来自于扫码成功后返回的uri 请求方式:GET | 参数 | 类型 | 参考值 | 说明 | |---------|--------|-------------------------------|----------| | ticket | string | AdbZxwhwQxDLnsAuzR@qrticket_0 | 系统返回值 | | uuid | string | Id8BhmDjUg== | 系统返回值 | | scan | int | 1715067458 | 系统返回值 | | lang | string | zh_CN | 系统返回值 | | fun | string | new | 固定值-额外添加 | | version | string | v2 | 固定值-额外添加 | | mod | string | desktop | 固定值-额外添加 | 返回值: ```xml 0 @crypt_465e6578_7540cc14f208be09a03bc79e67 OfQx4OB8uXb4U 3119590162 84IO0EF94nzHjwBT%eTlJY585WOYkUUKrBAA%3D%3D 1 ``` **注意!!!** **1.因为,不同的微信会指向不同的域名。需要获取当前请求链接的域名部分,用于后续请求的主域名** ``` #下面知道的域名,都和上面的请求返回来的域名是绑定的 https://wx.qq.com https://wx4.qq.com https://wx6.qq.com https://wx8.qq.com ``` **2.这里需要接收 请求response中返回携带的cookie 后续请求 必须携带cookie** ``` Set-Cookie: wxuin=3119590562; Domain=wx.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: wxsid=OfQx4OB8uqV4U; Domain=wx.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: wxloadtime=1715031469; Domain=wx.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: mm_lang=zh_CN; Domain=wx.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: wxuin=3119592562; Domain=.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: webwx_data_ticket=gSe/eJU31M0CthpSt39gT; Domain=.qq.com; Path=/; Expires=Tue, 07-May-2024 19:37:49 GMT; Secure Set-Cookie: webwx_auth_ticket=CIsBEKfYlaYCGoABWh6PTlKpO8aoWSQUU7FqzFj2VJOfchuC0pMfpdcjUPeG889C57abV/QCmdRFnHqfIkLeOHJDsFqSKXmTKLZo9VQ3UW+ZPE/McL14IDCminseD+iJD996xvMMXVbretrwpuuazhM/YbH010wV6rS8JeTNms=; Domain=wx.qq.com; Path=/; Expires=Fri, 05-May-2034 07:37:49 GMT; Secure ``` ---- ### 5.获取初始化 `mmwebwx-bin/webwxinit` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxinit` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |-------------|--------|--------------------------------------------|---------------------------------------| | r | int | -1373790379 | 获取13位毫秒时间戳 中的int64转int32然后取反 | | lang | string | zh_CN | 固定值 | | pass_ticket | string | 84IO0EF94nzHjwBT%eTlJY585WOYkUUKrBAA%3D%3D | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |-------------|------|------|-----------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" } } ``` 请求返回 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "Count": 1, "ContactList": [ { "Uin": 0, "UserName": "filehelper", "NickName": "文件ä1助手", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=7782009&username=filehelper&skey=@212312", "ContactFlag": 2, "MemberCount": 0, "MemberList": [], "RemarkName": "", "HideInputBarFlag": 0, "Sex": 0, "Signature": "", "VerifyFlag": 0, "OwnerUin": 0, "PYInitial": "WJCSZS", "PYQuanPin": "wenjianc1nshuzhushou", "RemarkPYInitial": "", "RemarkPYQuanPin": "", "StarFriend": 0, "AppAccountFlag": 0, "Statues": 0, "AttrStatus": 0, "Province": "", "City": "", "Alias": "", "SnsFlag": 0, "UniFriend": 0, "DisplayName": "", "ChatRoomId": 0, "KeyWord": "fil", "EncryChatRoomId": "", "IsOwner": 0 } ], "SyncKey": { "Count": 4, "List": [ { "Key": 1, "Val": 7187212286 }, { "Key": 2, "Val": 77323301 }, { "Key": 3, "Val": 713792216 }, { "Key": 1000, "Val": 171126703 } ] }, "User": { "Uin": 31195962, "UserName": "@7d7367c74ed24efe0a6194198a24b159ae072400386d67c050b9", "NickName": "â„–", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=813422765&username=@7d7367c74ed24efe0a6194198934159ae072400386d67c050b9&skey=@crypt_465e6578_7540cc14f208be0b319f19a03bc79e67", "RemarkName": "", "PYInitial": "", "PYQuanPin": "", "RemarkPYInitial": "", "RemarkPYQuanPin": "", "HideInputBarFlag": 0, "StarFriend": 0, "Sex": 0, "Signature": "", "AppAccountFlag": 0, "VerifyFlag": 0, "ContactFlag": 0, "WebWxPluginSwitch": 0, "HeadImgFlag": 1, "SnsFlag": 256 }, "ChatSet": "filehelper,@,weixin,@@,@fdd35109d1d7ff3c05ff9141cd9e6c49,fmessage,@0cde21143a127486f2a848e5a47c412bbb2a2b6020c5372fa581f76ba0dc5e41,filehelper,@5c622176dd3130c909c874cd0e2d1a3995e608f473300e93355e3a67c035bf2a,@b0e7a8d6fc1f3c842139b33d93c82b20,", "SKey": "@crypt_465e6574f319f19a03bc79e67", "ClientVersion": 671101239, "SystemTime": 1715067470, "GrayScale": 1, "InviteStartCount": 40, "MPSubscribeMsgCount": 1, "MPSubscribeMsgList": [ { "UserName": "@b0e7a8d6fc1f3c8421c82b20", "MPArticleCount": 1, "MPArticleList": [ { "Title": "任意品´é¢„算无上限!", "Digest": "海信以旧搯„高品质绿色新生活!", "Cover": "https://mmbiz.qpic.cn/mmbiz_jpg//640?wxtype=jpeg&wxfrom=0", "Url": "http://mp.weixin.qq.com/s?__biz===&mid=&idx=1&sn=&chksm=9affbef9ec9baaa78bcca17448d89de696a136e2b2107704515c9a20a1404663ec&scene=0&xtrack=1#rd" } ], "Time": 1714829047, "NickName": "海信爱家" } ], "ClickReportInterval": 600000 } ``` **下面是推荐 保存的参数** `其他参数,自行决定是否保存` ```json { "User": { "Uin": 3119590562, "UserName": "@7d7367c74e4198a24b8da385b69ae072467c050b9", "NickName": "â„–", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=813422765&username=@7d7367c724b8dae072400386d67c050b9&skey=@crypt_465ec0b319f19a03bc79e67", "RemarkName": "", "Sex": "0", "Province": "", "City": "" }, "SyncKey": { "Count": 4, "List": [ { "Key": 1, "Val": 778392286 }, { "Key": 2, "Val": 77192302 }, { "Key": 3, "Val": 778792216 }, { "Key": 1000, "Val": 1715167060 } ] } } ``` ---- ### 6.登录成功通知 `mmwebwx-bin/webwxstatusnotify` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxstatusnotify` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |-------------|--------|--------------------------------------------|---------------------------------------| | lang | string | zh_CN | 固定值 | | pass_ticket | string | 84IO0EF94nzHjwBT%eTlJY585WOYkUUKrBAA%3D%3D | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |--------------|--------|-------------------------------------|-----------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | ClientMsgId | int | 1715131917977 | 获取13位毫秒时间戳 | | Code | int | 3 | 固定值 | | FromUserName | string | @d3e285481828b5ee3dbf0346a7a0e99b58 | 发送者 账号本身 `username` | | ToUserName | string | @d3e285481828b5ee3dbf0346a7a0e99b58 | 接收者 账号本身 `username` | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" } } ``` 返回值 `自行判断是否处理` ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MsgID": "1876975500074575836" } ``` ---- ### 7.心跳 `mmwebwx-bin/synccheck` 请求链接:`https://webpush.[动态域名]/cgi-bin/mmwebwx-bin/synccheck` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |----------|--------|-------------------------------------------|---------------------------------------| | r | int | 1715132844959 | 获取13位毫秒时间戳 | | skey | string | @crypt_465e6578_a3b8d0a945dd5d8d | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | sid | string | /5Wko4hTr6T | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | uin | int | 1111210512 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | deviceid | string | e968730629287437 | e + 15位随机数 | | synckey | string | ` 1_778792286\| 2_778792334\|3_778792216` | 获取`mmwebwx-bin/webwxinit`的返回值进行\|进行拼接 | | _ | int | 1715132040405 | 开始时间的 13位毫秒时间戳 以后每请求一次+1 | 返回值 ``` window.synccheck={retcode:"0",selector:"0"} ``` 参数说明: | retcode | 说明 | |---------|-----------| | 0 | 正常 | | 1100 | 失败/登出微信 | | 1101 | 微信在其他地方登录 | | 1102 | 微信退出 | | selector | 说明 | |----------|-------------------| | 0 | 正常 | | 2 | 新消息 | | 4 | 通过时发现,删除好友 | | 6 | 删除时发现和对方通过好友验证 | | 7 | 进入/离开聊天界面 (可能没有了) | ** 上面就是登录流程-只要一直请求心跳就可以活着 ** ---- ## 接收消息和文件 ### 1.接收消息列表 `mmwebwx-bin/webwxsync` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxsync` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |-------------|--------|--------------------------------------------|---------------------------------------| | sid | string | pZ112KPu3RNzNO3 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | skey | string | @crypt_1dbbc087_6a0f3 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | lang | string | zh_CN | 固定值 | | pass_ticket | string | 84IO0EF94nzHjwBT%eTlJY585WOYkUUKrBAA%3D%3D | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |-------------|------|------|-------------------------------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | SyncKey | int | `示例` | 获取`mmwebwx-bin/webwxinit` 的返回值 无需修改直接填充就行 | | rr | int | 3 | 获取13位毫秒时间戳 int64转换为int32以后取反 | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" }, "SyncKey": { "Count": 4, "List": [ { "Key": 1, "Val": 778392286 }, { "Key": 2, "Val": 77192302 }, { "Key": 3, "Val": 778792216 }, { "Key": 1000, "Val": 1715167060 } ] } } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "AddMsgCount": 1, "AddMsgList": [ { "MsgId": "194222512198", "FromUserName": "@d3e285481828b5ee3dbf0317f7f82b5b", "ToUserName": "@d3e285481828b56d17f7f82b5b", "MsgType": 51, "Content": "", "Status": 3, "ImgStatus": 1, "CreateTime": 1715131925, "VoiceLength": 0, "PlayLength": 0, "FileName": "", "FileSize": "", "MediaId": "", "Url": "", "AppMsgType": 0, "StatusNotifyCode": 4, "StatusNotifyUserName": "@@filehe54e8f3d4cb9fa41cc70d51ee11d71a4,@@filehe54e8f3d4cb9fa41cc70d51ee11d71a4", "RecommendInfo": { "UserName": "", "NickName": "", "QQNum": 0, "Province": "", "City": "", "Content": "", "Signature": "", "Alias": "", "Scene": 0, "VerifyFlag": 0, "AttrStatus": 0, "Sex": 0, "Ticket": "", "OpCode": 0 }, "ForwardFlag": 0, "AppInfo": { "AppID": "", "Type": 0 }, "HasProductId": 0, "Ticket": "", "ImgHeight": 0, "ImgWidth": 0, "SubMsgType": 0, "NewMsgId": 19422225251989143, "OriContent": "", "EncryFileName": "" } ], "ModContactCount": 0, "ModContactList": [], "DelContactCount": 0, "DelContactList": [], "ModChatRoomMemberCount": 0, "ModChatRoomMemberList": [], "Profile": { "BitFlag": 0, "UserName": { "Buff": "" }, "NickName": { "Buff": "" }, "BindUin": 0, "BindEmail": { "Buff": "" }, "BindMobile": { "Buff": "" }, "Status": 0, "Sex": 0, "PersonalCard": 0, "Alias": "", "HeadImgUpdateFlag": 0, "HeadImgUrl": "", "Signature": "" }, "ContinueFlag": 0, "SyncKey": { "Count": 14, "List": [ { "Key": 1, "Val": 839276376 }, { "Key": 2, "Val": 839276437 }, { "Key": 3, "Val": 839276312 }, { "Key": 1000, "Val": 1715124660 }, { "Key": 1001, "Val": 1715124661 } ] }, "SKey": "", "SyncCheckKey": { "Count": 14, "List": [ { "Key": 1, "Val": 839276376 }, { "Key": 2, "Val": 839276437 }, { "Key": 3, "Val": 839276312 }, { "Key": 1000, "Val": 1715124660 }, { "Key": 1001, "Val": 1715124661 } ] } } ``` **下面是推荐 保存的参数** `其他参数,自行决定是否保存` 下方获取到的 SyncKey 需要更新到全局让下一次携带请求 这个最新的,不然会出现消息叠加无法清除的情况 ```json { "AddMsgList": [ { "MsgId": "194222252512143", "FromUserName": "@d3e285481828ba0e99b581756d17f7f82b5b", "ToUserName": "@d3e285481828b5ee3dbf034617f7f82b5b", "MsgType": 51, "Content": "", "FileName": "", "FileSize": "", "MediaId": "", "Ticket": "", "RecommendInfo": { "UserName": "", "NickName": "", "Ticket": "" } } ], "SyncKey": { "Count": 14, "List": [ { "Key": 1, "Val": 839276376 }, { "Key": 2, "Val": 839276437 }, { "Key": 3, "Val": 839276312 }, { "Key": 1000, "Val": 1715124660 }, { "Key": 1001, "Val": 1715124661 } ] } } ``` 参数说明 | MsgType | 解释 | |---------|--------------------| | 1 | 文本消息 | | 3 | 图片消息 | | 34 | 语音消息 | | 37 | VERIFYMSG 好友验证消息 | | 40 | POSSIBLEFRIEND_MSG | | 42 | 共享名片 | | 43 | 视频通话消息 | | 47 | 动画表情 | | 48 | 位置消息 | | 49 | 分享链接 | | 50 | VOIPMSG | | 51 | 微信初始化消息 | | 52 | VOIPNOTIFY | | 53 | VOIPINVITE | | 62 | 小视频 | | 9999 | SYSNOTICE | | 10000 | 系统消息 | | 10002 | 撤回消息 | ---- ### 2.获取图片 `mmwebwx-bin/webwxgetmsgimg` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgetmsgimg` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |-------|--------|-------------------------------------|-------------------------------------| | MsgID | string | 221396120159200694 | 在 `mmwebwx-bin/webwxsync` 获取的 | | skey | string | @crypt_465e6578_a3b8d0a945dd5d8da1f | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | type | string | slave | 固定值:如果不传递这个值,获取到的是原图, slave:缩率图 | 返回值 ``` 图片文件 ``` ---- ### 3.获取视频 `mmwebwx-bin/webwxgetvideo` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgetvideo` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |-------|--------|-------------------------------------|-------------------------------------| | msgid | string | 221396120159200694 | 在 `mmwebwx-bin/webwxsync` 获取的 | | skey | string | @crypt_465e6578_a3b8d0a945dd5d8da1f | 在`mmwebwx-bin/webwxnewloginpage`获取的 | 返回值 ``` mp4 文件 ``` 如果需要获取视频封面图片,请使用 `mmwebwx-bin/webwxgetmsgimg` ---- ### 4.获取音频 `mmwebwx-bin/webwxgetvoice` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgetvoice` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |-------|--------|-------------------------------------|-------------------------------------| | msgid | string | 221396120159200694 | 在 `mmwebwx-bin/webwxsync` 获取的 | | skey | string | @crypt_465e6578_a3b8d0a945dd5d8da1f | 在`mmwebwx-bin/webwxnewloginpage`获取的 | 返回值 ``` mp3文件 ``` ### 5.获取文件 `mmwebwx-bin/webwxgetmedia` 请求链接:`https://file.[动态域名]/cgi-bin/mmwebwx-bin/webwxgetmedia` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |-------------------|--------|-------------------------------------|-----------------------------------------------| | sender | string | 221396120159200694 | 在 `mmwebwx-bin/webwxsync` 获取的 `FromUserName` | | mediaid | string | @crypt_465e6578_a3b8d0a945dd5d8da1f | 在`mmwebwx-bin/webwxsync`获取的 | | encryfilename | string | session.log | 在`mmwebwx-bin/webwxsync`获取的 `filename` | | fromuser | string | 3119590562 | 在 `mmwebwx-bin/webwxinit` 获取的 `uin` | | pass_ticket | string | undefined | 固定值 设置为`undefined` | | webwx_data_ticket | string | SerPZEe0aq6RnELrtO%2BEV%2FX | 在 `mmwebwx-bin/webwxnewloginpage` 中cookie中获取的 | 返回值 ``` 下载文件 ``` ---- ## 上传文件 ### 1.上传文件 `mmwebwx-bin/webwxuploadmedia` 请求链接:`https://file.[动态域名]/cgi-bin/mmwebwx-bin/webwxuploadmedia` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | | Content-Type | multipart/form-data | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |----|--------|------|-----| | f | string | json | 固定值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |--------------------|--------|--------------------------------------------|-------------------------------------------------------| | id | string | WU_FILE_0 | WU_FILE_固定的后面的数字是如果当前从0开始上传+1 | | name | string | 2024-04-29.log | 文件名称 | | type | string | application/octet-stream | 文件类型 识别不出来的话`application/octet-stream` | | lastModifiedDate | string | Tue Apr 30 2024 08:04:31 GMT+0800 (中国标准时间) | 获取文件修改时间 | | size | int | 5542 | 文件大小 | | mediatype | string | doc | 文件类型:图片-pic,文件-dock | | uploadmediarequest | string | 示例 | 请查看 参数详解 `Uploadmediarequest` 把这个类型json转换成string | | webwx_data_ticket | string | SerPZEe03RnELrtO+EV/Z | 在 `mmwebwx-bin/webwxnewloginpage` 中cookie中获取的 | | pass_ticket | string | undefined | 文件-undefined,图片-获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | filename | byte | -- | 文件二进制内容 | 示例 ```json { UploadType: 2, BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e657c14f208be0b319f19a", Uin: "3119590562" }, ClientMediaId: 1715152326175, TotalLen: 5542, StartPos: 0, DataLen: 5542, MediaType: 4, FromUserName: "@e97a757b105a22c6190adc55a6", ToUserName: "@10ee4363882953886ad32b65f", FileMd5: "8852ba8c58c9f1d67c4" } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MediaId": "@crypt_3f8d6bec_dd014e737a1b3879e055ec3", "StartPos": 5542, "CDNThumbImgHeight": 0, "CDNThumbImgWidth": 0, "EncryFileName": "2D04%2D29%2Elog" } ``` ---- ## 发送消息 ### 1.发送文本消息 `mmwebwx-bin/webwxsendmsg` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxsendmsg` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |-------------|------|------|---------------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | Msg | json | `示例` | 请查看 参数详解`WebwxsendmsgMsg` | | Scene | int | 0 | 固定值 | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" }, Msg: { ClientMsgId: "17151485742880415", Content: "1", FromUserName: "@e97af105880245bca4432ef4dbf9cb170def62420a757b105a22c6190adc55a6", LocalID: "17151485742880415", ToUserName: "@10ee43ed38ccc983978486f37cc6de973c14e527e876e63882953886ad32b65f", Type: 1 } } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MsgID": "7932710120851626854", "LocalID": "17151485742880415" } ``` ---- ### 2.发送图片消息 `mmwebwx-bin/webwxsendmsgimg` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxsendmsgimg` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |-----|--------|-------|-----| | fun | string | async | 固定值 | | f | string | json | 固定值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |-------------|------|------|------------------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | Msg | json | `示例` | 请查看 参数详解`WebwxsendmsgimgMsg` | | Scene | int | 0 | 固定值 | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" }, Msg: { ClientMsgId: "17151517808720232", Content: "", FromUserName: "@dseqwe", LocalID: "17151517808720232", MediaId: "@crypt_3f8d6bec_dd014e737a1b3879e055ec3", ToUserName: "@adsasd", Type: 3 } } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MsgID": "6835225771829175967", "LocalID": "17151517808720232" } ``` --- ### 3.发送文件消息 `mmwebwx-bin/webwxsendappmsg` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxsendappmsg` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |-----|--------|---------|-----| | fun | string | async | 固定值 | | f | string | json | 固定值 | | mod | string | desktop | 固定值 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |-------------|------|------|------------------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | Msg | json | `示例` | 请查看 参数详解`WebwxsendappmsgMsg` | | Scene | int | 0 | 固定值 | 示例 ```json { BaseRequest: { DeviceID: "e447611664736281", Sid: "OfQx4OB8uXb5qV4U", Skey: "@crypt_465e6578_7540cc14f208be0b319f19a", Uin: "3119590562" }, Msg: { ClientMsgId: "17151523261130626", Content: "2024-04-29.log65542@crypt_3f8d6bec_dd0122788204a39ce1921d078f76fab259fc21da1770963baec08ea1c43306fecad1bfbdc3b936baf82090adab5ac85059eff73f7814ecc4bcb275b45d594441a7d19bba866460782695b1d65e84f77fd29ffb8fd67656161ec4900ea174f3e2a75c9a0dc5189acf789db594bfc7160499768a24b8868cc52c3cf0a5b227e7ec19b49e94b7dea0c70da6737a1b3879e055ec3log", FromUserName: "@e97af105880245bca4432ef4dbf9cb170def62420a757b105a22c6190adc55a6", LocalID: "17151523261130626", ToUserName: "@10ee43ed38ccc983978486f37cc6de973c14e527e876e63882953886ad32b65f", Type: 6 } } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MsgID": "4025852770617041549", "LocalID": "17151523261130626" } ``` ---- ## 获取头像 和 群头像 ### 1.获取用户头像 `mmwebwx-bin/webwxgeticon` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgeticon` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |----------|--------|------------------------------------------|-------------------------------------| | seq | string | 778792007 | 获取13位毫秒时间戳 中的int64转int32 | | username | string | @a4643f97a11831aff72b5f188d610c96c0f238e | 用户的`username` | | skey | string | @crypt_465e6578_a3b8d0abe0ace | 在`mmwebwx-bin/webwxnewloginpage`获取的 | 返回值 avatar.jpg ---- ### 2.获取群头像 `mmwebwx-bin/webwxgetheadimg` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgetheadimg` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |----------|--------|-------------------------------------------|-------------------------------------| | seq | string | 0 | 固定值 | | username | string | @@a4643f97a11831aff72b5f188d610c96c0f238e | 群的`username` | | skey | string | @crypt_465e6578_a3b8d0abe0ace | 在`mmwebwx-bin/webwxnewloginpage`获取的 | 返回值 avatar.jpg ---- ## 扩展服务 ### 1.同意好友申请 `mmwebwx-bin/webwxverifyuser` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxverifyuser` 请求方式:POST 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 参数:GET | 参数 | 类型 | 参考值 | 说明 | |----|-----|---------------|------------| | r | int | 1715132844959 | 获取13位毫秒时间戳 | 参数:POST `内含多重嵌套请求请看示例` | 参数 | 类型 | 参考值 | 说明 | |--------------------|--------|------------------------------|---------------------------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | Opcode | int | 3 | 固定值 | | SceneList | array | {33} | 固定值 | | SceneListCount | int | 1 | 固定值 | | VerifyContent | string | "" | 为空 | | VerifyUserList | array | `示例` | 请查看 参数详解`VerifyUserList` | | VerifyUserListSize | int | 1 | 根据`VerifyUserList` 获取数量 | | Skey | Skey | @crypt_4636578_754003bc79e67 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | 示例 ```json { BaseRequest: { DeviceID: "e447611636281", Sid: "OfQx4OB8uXb54U", Skey: "@crypt_465e6578_754208be0b319f19a", Uin: "3119590562" }, VerifyUserList: [ { Value: "@312123123123123", VerifyUserTicket: "1ads23de12121asd3s12" } ] } ``` 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" } } ``` ---- ### 2.获取好友列表和公众号列表 `mmwebwx-bin/webwxgetcontact` 请求链接:`https://[动态域名]/cgi-bin/mmwebwx-bin/webwxgetcontact` 请求方式:GET 自定义Header: | Key | Value | |----------------|-------------------------------------| | cookie | 在`mmwebwx-bin/webwxnewloginpage`获取的 | | Extspam | 请查参数详解 `Extspam` | | Client-Version | 固定值 `Client-Version` | 请求参数 | 参数 | 类型 | 参考值 | 说明 | |------|-----|----------------------|---------------------------------------| | lang | int | zh_CN | 固定值 | | r | int | 1715132844959 | 获取13位毫秒时间戳 | | seq | int | 0 | 固定值 | | skey | int | @crypt_465e6578_7f39 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | 返回值 ```json { "BaseResponse": { "Ret": 0, "ErrMsg": "" }, "MemberCount": 1, "MemberList": [ { "Uin": 0, "UserName": "weixin", "NickName": "å¾®ä队", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=7150083&username=weixin&skey=@crypt_4806419b4b99", "ContactFlag": 3, "MemberCount": 0, "MemberList": [], "RemarkName": "", "HideInputBarFlag": 0, "Sex": 0, "Signature": "微信团å·", "VerifyFlag": 56, "OwnerUin": 0, "PYInitial": "WXTD", "PYQuanPin": "weixintuandui", "RemarkPYInitial": "", "RemarkPYQuanPin": "", "StarFriend": 0, "AppAccountFlag": 0, "Statues": 0, "AttrStatus": 4, "Province": "", "City": "", "Alias": "", "SnsFlag": 0, "UniFriend": 0, "DisplayName": "", "ChatRoomId": 0, "KeyWord": "wei", "EncryChatRoomId": "", "IsOwner": 0 } ], "Seq": 0 } ``` ---- ## 参数详解 ### BaseRequest | 参数 | 类型 | 参考值 | 说明 | |----------|--------|-------------------------------------------------|---------------------------------------| | DeviceID | string | e447611661736281 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | Sid | string | OfQx4OB8uX25q14U | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | Skey | Skey | @crypt_4636578_7540cc14f208be0b319f19a03bc79e67 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | | Uin | Uin | 3119193562 | 获取`mmwebwx-bin/webwxnewloginpage`的返回值 | ---- ### WebwxsendmsgMsg | 参数 | 类型 | 参考值 | 说明 | |--------------|--------|-------------------------|-------------------| | ClientMsgId | int | 17151485742880415 | 获取17位毫秒 | | Content | string | `你好` | 发送内容 | | FromUserName | string | @e97af105880245bca443 | 发送者 | | ToUserName | string | @10ee43ed38ccc983978486 | 接收者 | | LocalID | int | 17151485742880415 | 和`ClientMsgId` 同值 | | Type | int | 1 | 固定值 | ---- ### WebwxsendmsgimgMsg | 参数 | 类型 | 参考值 | 说明 | |--------------|--------|-----------------------------------------|----------------------------------------| | ClientMsgId | int | 17151485742880415 | 获取17位毫秒 | | Content | string | "" | 发送内容设置为空 | | FromUserName | string | @e97af105880245bca443 | 发送者 | | ToUserName | string | @10ee43ed38ccc983978486 | 接收者 | | MediaId | string | @crypt_3f8d6bec_dd014e737a1b3879e055ec3 | 获取 `mmwebwx-bin/webwxuploadmedia` 的返回值 | | LocalID | int | 17151485742880415 | 和`ClientMsgId` 同值 | | Type | int | 3 | 固定值 | ---- ### WebwxsendappmsgMsg | 参数 | 类型 | 参考值 | 说明 | |--------------|--------|-------------------------|-------------------| | ClientMsgId | int | 17151485742880415 | 获取17位毫秒 | | Content | string | `示例` | 查看示例xml | | FromUserName | string | @e97af105880245bca443 | 发送者 | | ToUserName | string | @10ee43ed38ccc983978486 | 接收者 | | LocalID | int | 17151485742880415 | 和`ClientMsgId` 同值 | | Type | int | 6 | 固定值 | 示例 ```xml 2024-04-29.log 6 5542 @crypt_3f8d6bec_dd0122788204a39ce1921d0814ecc4bcb275b19b49e94b7dea0c70da6737a1b3879e055ec3 log ``` ---- ### Uploadmediarequest | 参数 | 类型 | 参考值 | 说明 | |---------------|--------|----------------------------------|-----------------------| | BaseRequest | json | `示例` | 请查看 参数详解`BaseRequest` | | ClientMediaId | int | 1715152326175 | 获取13位毫秒时间戳 | | TotalLen | int | 5542 | 文件大小 | | StartPos | int | 0 | 开始位置 固定值 | | DataLen | int | 5542 | 数据大小 | | MediaType | int | 4 | 固定值 | | FromUserName | string | @e974dbf9cb170defc55a6 | 发送者 | | ToUserName | string | @10ee43ed38ccc | 接收者 | | FileMd5 | string | 88523f1172ea4e6bfba8c58c9f1d67c4 | 文件的MD5 | ---- ### VerifyUserList | 参数 | 类型 | 参考值 | 说明 | |------------------|--------|----------------------|--------------------------------------------------------------------| | Value | string | @312123123123123 | 获取`mmwebwx-bin/webwxsync`返回值 `AddMsgList->RecommendInfo->UserName` | | VerifyUserTicket | string | 1ads23de12121asd3s12 | 获取`mmwebwx-bin/webwxsync`返回值 `AddMsgList->RecommendInfo->Ticket` | ---- ### Client-Version | 参数 | 类型 | 参考值 | 说明 | |----------------|--------|-------|-----| | Client-Version | string | 2.0.0 | 固定值 | ---- ### Extspam | 参数 | 类型 | 参考值 | 说明 | |---------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----| | Extspam | string | `Go8FCIkFEokFCggwMDAwMDAwMRAGGvAESySibk50w5Wb3uTl2c2h64jVVrV7gNs06GFlWplHQbY/5FfiO++1yH4ykCyNPWKXmco+wfQzK5R98D3so7rJ5LmGFvBLjGceleySrc3SOf2Pc1gVehzJgODeS0lDL3/I/0S2SSE98YgKleq6Uqx6ndTy9yaL9qFxJL7eiA/R3SEfTaW1SBoSITIu+EEkXff+Pv8NHOk7N57rcGk1w0ZzRrQDkXTOXFN2iHYIzAAZPIOY45Lsh+A4slpgnDiaOvRtlQYCt97nmPLuTipOJ8Qc5pM7ZsOsAPPrCQL7nK0I7aPrFDF0q4ziUUKettzW8MrAaiVfmbD1/VkmLNVqqZVvBCtRblXb5FHmtS8FxnqCzYP4WFvz3T0TcrOqwLX1M/DQvcHaGGw0B0y4bZMs7lVScGBFxMj3vbFi2SRKbKhaitxHfYHAOAa0X7/MSS0RNAjdwoyGHeOepXOKY+h3iHeqCvgOH6LOifdHf/1aaZNwSkGotYnYScW8Yx63LnSwba7+hESrtPa/huRmB9KWvMCKbDThL/nne14hnL277EDCSocPu3rOSYjuB9gKSOdVmWsj9Dxb/iZIe+S6AiG29Esm+/eUacSba0k8wn5HhHg9d4tIcixrxveflc8vi2/wNQGVFNsGO6tB5WF0xf/plngOvQ1/ivGV/C1Qpdhzznh0ExAVJ6dwzNg7qIEBaw+BzTJTUuRcPk92Sn6QDn2Pu3mpONaEumacjW4w6ipPnPw+g2TfywJjeEcpSZaP4Q3YV5HG8D6UjWA4GSkBKculWpdCMadx0usMomsSS/74QgpYqcPkmamB4nVv1JxczYITIqItIKjD35IGKAUwAA==` | 固定值 | ---- ## AI ### 安装和使用 我这使用的是使用 `ollama` 安装方式 请看ollama官方:https://github.com/ollama/ollama 我这是使用 `llama3:8b`的模型