pc vx hook

微信


[监控] 实时消息接收发送

[TOC]

简要描述
  • 接收实时消息, 本接口需自行搭建。用来接收微信实时消息。
如果没有指定消息回调URL。默认发送给以下URL地址
  • http://127.0.0.1:30000/api/user/recive_msg
发送方式
  • POST
发送参数 当https://www.showdoc.com.cn/ebaiwl/9204125262722344 接口传递参数为2 时
{
    "ServerPort":"30001",
    "selfwxid":"wxid_123456",
    "sendorrecv":"2",
    "pb_data":"0A058C6EA223445F1C...",
}
发送参数 当https://www.showdoc.com.cn/ebaiwl/9204125262722344 接口传递参数为1 时

PC端 发送的消息

PC发出文本消息 第一次 发送的内容

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:07:54",
            "msgtype":"1",
            "msgsvrid":"",
            "msg":"大佬666~",
            "fromwxid":"themid",
            "toid":"filehelper"
        }]
}

第二次 发送成功后 收到 服务器返回的消息ID (msgid)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:07:54",
            "msgtype":"1",
            "msgsvrid":"7029814402633277009",
            "msg":"PC发文本消息成功",
            "fromwxid":"themid",
            "toid":"filehelper"
        }]
}

PC发出图片消息 第一次 发送的内容

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"0",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:09:19",
            "msgtype":"3",
            "msgsvrid":"",
            "msg":"8bb306d0ad78a2aa8cafe229dc304f38",
            "fromwxid":"themid",
            "toid":"filehelper",
            "img_path":"C:\\\\Users\\\\Administrator\\\\Documents\\\\WeChat Files\\\\thexed\\\\FileStorage\\\\Temp\\\\1677992958058.jpg"
        }]
}

第二次 发送成功后 收到 服务器返回的消息ID (msgid)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:09:20",
            "msgtype":"3",
            "msgsvrid":"8676825236427018921",
            "msg":"PC发图片消息成功",
            "fromwxid":"themid",
            "toid":"filehelper"
        }]
}

PC发出文件/app消息 第一次 发送的内容

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"0",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:11:27",
            "msgtype":"49",
            "msgsvrid":"",
            "msg":"version.dll",
            "fromwxid":"themid",
            "toid":"filehelper",
            "file_path":"C:\\\\Users\\\\Administrator\\\\Desktop\\\\version.dll"
        }]
}

第二次 发送成功后 收到 服务器返回的消息ID (msgid)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:11:30",
            "msgtype":"99",
            "msgsvrid":"476728224034532762",
            "msg":"PC发app/文件消息成功",
            "fromwxid":"themid",
            "toid":"filehelper"
        }]
}

PC发出视频消息 第一次 发送的内容

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"0",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:14:07",
            "msgtype":"4",
            "msgsvrid":"",
            "msg":"3057020100044b30490201000204911740bc02032f77f50204ab5b90db02046404251f042438373463386566632d396161312d346263642d383838392d3335613736613865396634610204011400030201000405004c550500",
            "fromwxid":"themid",
            "toid":"filehelper",
            "video_path":"C:\\\\Windows\\\\SystemApps\\\\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\\\\media\\\\oobe-intro.mp4"
        }]
}

第二次 发送成功后 收到 服务器返回的消息ID (msgid)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:14:11",
            "msgtype":"36",
            "msgsvrid":"3847230082234559699",
            "msg":"PC发视频文件成功",
            "fromwxid":"themid",
            "toid":""
        }]
}

切换聊天对象

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:04:26",
            "msgtype":"10000",
            "msgsvrid":"",
            "msg":"切换聊天对象",
            "current_wxid":"filehelper",
            "name":"文件传输助手",
            "nickname":""
        }]
}

PC端 收到的消息(图片)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"2",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:25:47",
            "msgtype":"51",
            "msgsvrid":"6229442408328493980",
            "msg":"<msg>\n<op id='1'>\n<username>wxid_kq...</username>\n<name>lastMessage</name>\n<arg>{\"messageSvrId\":\"0\",\"MsgCreateTime\":\"1677993947\"}</arg>\n</op>\n</msg>",
            "fromwxid":"themid",
            "toid":"wxid_kq..."
        },{
            "index":"2",
            "time":"2023-03-05 13:25:47",
            "msgtype":"3",
            "msgsvrid":"1205604146658880283",
            "msg":"<?xml version=\"1.0\"?>\n<msg>\n\t<img aeskey=\"7c2724b850f88a..f40631abe\" encryver=\"1\" cdnthumbaeskey=\"7c2...f40631abe\" cdnthumburl=\"3057020..4640427db042461656539336534642d376661302d343136312d3..3738313836020401150a020201000405004c4f2900\" cdnthumblength=\"1994\" cdnthumbheight=\"120\" cdnthumbwidth=\"67\" cdnmidheight=\"0\" cdnmidwidth=\"0\" cdnhdheight=\"0\" cdnhdwidth=\"0\" cdnmidimgurl=\"3057020100..0a0202c4f2900\" length=\"273129\" md5=\"67025..90cc261\" hevc_mid_size=\"273129\" />\n\t<platform_signature></platform_signature>\n\t<imgdatahash></imgdatahash>\n</msg>\n",
            "img_path":"C:\\Users\\Administrator\\Documents\\WeChat Files\\themid\\FileStorage\\MsgAttach\\81a7f2695cd..599f\\Image\\2023-03\\e0f480bb..bfdd1e634.dat",
            "fromwxid":"themid",
            "toid":"wxid_kq.."
        }]
}

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgsvrid":"1957754625548008208",
    "img_path":"C:\\Users\\Administrator\\Documents\\WeChat Files\\themid\\FileStorage\\MsgAttach\\81a7..599f\\Image\\2023-03\\ba649..df2.dat",
    "time":"2023-03-05 13:25:47",
    "msg":"<?xml version=\"1.0\"?>\n<msg>\n\t<img aeskey=\"7c2724b..1abe\" encryver=\"1\" cdnthumbaeskey=\"7c272..abe\" cdnthumburl=\"3057020..c4f2900\" cdnthumblength=\"1994\" cdnthumbheight=\"120\" cdnthumbwidth=\"67\" cdnmidheight=\"0\" cdnmidwidth=\"0\" cdnhdheight=\"0\" cdnhdwidth=\"0\" cdnmidimgurl=\"3057020..2900\" length=\"273129\" md5=\"67..c261\" hevc_mid_size=\"273129\" />\n\t<platform_signature></platform_signature>\n\t<imgdatahash></imgdatahash>\n</msg>\n"
}

PC端 收到的消息(GIF动图)


{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2022-12-22 18:15:08",
            "msgtype":"47",
            "msgsvrid":"9168432254856816012",
            "msg":"<msg><emoji fromusername = \"thekid\" tousername = \"themid\" type=\"2\" idbuffer=\"media:0_0\" md5=\"97365663bee2eb41ea0b3ad50cbe9dd2\" len = \"439919\" productid=\"\" androidmd5=\"97365663bee2eb41ea0b3ad50cbe9dd2\" androidlen=\"439919\" s60v3md5 = \"97365663bee2eb41ea0b3ad50cbe9dd2\" s60v3len=\"439919\" s60v5md5 = \"97365663bee2eb41ea0b3ad50cbe9dd2\" s60v5len=\"439919\" cdnurl = \"http://vweixinf.tc.qq.com/110/20401/stodownload?m=97365663bee2eb41ea0b3ad50cbe9dd2&filekey=30440201010430302e02016e0402535a04203937333635363633626565326562343165613062336164353063626539646432020306b66f040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303033653932336261623532663833353335383538303930303030303036653031303034666231&ef=1&bizid=1022\" designerid = \"\" thumburl = \"\" encrypturl = \"http://vweixinf.tc.qq.com/110/20402/stodownload?m=ea1bd1936ce3281e92a72ed45653a768&filekey=30440201010430302e02016e0402535a04206561316264313933366365333238316539326137326564343536353361373638020306b670040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303034376139626261623532663833353335383538303930303030303036653032303034666232&ef=2&bizid=1022\" aeskey= \"658d8cd15a6d4573990cd63ebb0d4e70\" externurl = \"http://vweixinf.tc.qq.com/110/20403/stodownload?m=bf191d0d4bc5d7de00a08b16960c3c74&filekey=30440201010430302e02016e0402535a0420626631393164306434626335643764653030613038623136393630633363373402030422c0040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303036353639326261623532663833353335383538303930303030303036653033303034666233&ef=3&bizid=1022\" externmd5 = \"870b23321c54bce14f843a037a746989\" width= \"512\" height= \"512\" tpurl= \"\" tpauthkey= \"\" attachedtext= \"\" attachedtextcolor= \"\" lensid= \"\" emojiattr= \"\" linkid= \"\" desc= \"\" ></emoji> <gameext type=\"0\" content=\"0\" ></gameext></msg>",
            "gif_url":"http://vweixinf.tc.qq.com/110/20401/stodownload?m=97365663bee2eb41ea0b3ad50cbe9dd2&filekey=30440201010430302e02016e0402535a04203937333635363633626565326562343165613062336164353063626539646432020306b66f040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303033653932336261623532663833353335383538303930303030303036653031303034666231&ef=1&bizid=1022",
            "fromwxid":"thekid",
            "toid":"themid",
            "tonickname":"",
            "toname":"",
            "tohead":""
        }]
}
{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgsvrid":"10116766129219189887",
    "gif_url":"http://vweixinf.tc.qq.com/110/20401/stodownload?m=97365663bee2eb41ea0b3ad50cbe9dd2&filekey=30440201010430302e02016e0402535a04203937333635363633626565326562343165613062336164353063626539646432020306b66f040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303033653932336261623532663833353335383538303930303030303036653031303034666231&ef=1&bizid=1022",
    "time":"2022-12-22 18:15:08",
    "msg":"<msg><emoji fromusername = \"thekid\" tousername = \"themid\" type=\"2\" idbuffer=\"media:0_0\" md5=\"97365663bee2eb41ea0b3ad50cbe9dd2\" len = \"439919\" productid=\"\" androidmd5=\"97365663bee2eb41ea0b3ad50cbe9dd2\" androidlen=\"439919\" s60v3md5 = \"97365663bee2eb41ea0b3ad50cbe9dd2\" s60v3len=\"439919\" s60v5md5 = \"97365663bee2eb41ea0b3ad50cbe9dd2\" s60v5len=\"439919\" cdnurl = \"http://vweixinf.tc.qq.com/110/20401/stodownload?m=97365663bee2eb41ea0b3ad50cbe9dd2&filekey=30440201010430302e02016e0402535a04203937333635363633626565326562343165613062336164353063626539646432020306b66f040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303033653932336261623532663833353335383538303930303030303036653031303034666231&ef=1&bizid=1022\" designerid = \"\" thumburl = \"\" encrypturl = \"http://vweixinf.tc.qq.com/110/20402/stodownload?m=ea1bd1936ce3281e92a72ed45653a768&filekey=30440201010430302e02016e0402535a04206561316264313933366365333238316539326137326564343536353361373638020306b670040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303034376139626261623532663833353335383538303930303030303036653032303034666232&ef=2&bizid=1022\" aeskey= \"658d8cd15a6d4573990cd63ebb0d4e70\" externurl = \"http://vweixinf.tc.qq.com/110/20403/stodownload?m=bf191d0d4bc5d7de00a08b16960c3c74&filekey=30440201010430302e02016e0402535a0420626631393164306434626335643764653030613038623136393630633363373402030422c0040d00000004627466730000000131&hy=SZ&storeid=323032313035303731393134333530303036353639326261623532663833353335383538303930303030303036653033303034666233&ef=3&bizid=1022\" externmd5 = \"870b23321c54bce14f843a037a746989\" width= \"512\" height= \"512\" tpurl= \"\" tpauthkey= \"\" attachedtext= \"\" attachedtextcolor= \"\" lensid= \"\" emojiattr= \"\" linkid= \"\" desc= \"\" ></emoji> <gameext type=\"0\" content=\"0\" ></gameext></msg>"
}

PC端 收到的消息(语音消息)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:19:05",
            "msgtype":"34",
            "msgsvrid":"3921037281184911662",
            "msg":"<msg><voicemsg endflag=\"1\" cancelflag=\"0\" forwardflag=\"0\" voiceformat=\"4\" voicelength=\"1980\" length=\"2972\" bufid=\"0\" aeskey=\"18987a920fd...ae5b2b6a245\" voiceurl=\"305202010004...4000f0201000400\" voicemd5=\"\" clientmsgid=\"49026462e24bee876...3cb70cthemid_19_1677993542\" fromusername=\"wxid_kqi...\" /></msg>",
            "voip_data":"02232153494C4B5F56331200A738B8AACFF7B149A2093860..",
            "fromwxid":"wxid_kqi..2",
            "toid":"themid"
        }]
}

PC端 收到的消息(退出登陆微信)

{
    "ServerPort":"30001",
    "selfwxid":"themid",
    "sendorrecv":"1",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-03-05 13:23:06",
            "msgtype":"10000",
            "msgsvrid":"",
            "msg":"退出登录微信"
        }]
}

PC端 拉人进群通知

{
    "ServerPort":"30001",
    "selfwxid":"wxid_kqis...",
    "sendorrecv":"2",
    "msgnumber":"1",
    "msglist":[{
            "index":"1",
            "time":"2023-01-09 17:23:26",
            "msgtype":"20001",
            "msg":"Everything is OK",
            "gid":"43202784070@chatroom"
        }]
}
参数说明
参数名 必选 类型 说明
ServerPort string 发送消息的端口默认30001,如果是30002则代表第二个微信
selfwxid string 本人微信ID
sendorrecv string 1=收到的消息 </br>2=发送的消息
msgnumber string 本次收到/发送的消息数量
businesstype string 业务类型代码
businessdata string 业务数据(16进制protobuf文本)
time string 收到消息的时间
msgtype string 消息类型代码
device string 设备代码 手机=1 其他=0
fromwxid string 发送方微信ID
toid string 接收人微信ID/群ID
msg string 消息内容
msgsvrid string 服务器消息ID,用于撤回,或者下载图片/视频/文件
img_path string 如果当前收到的是图片,则会显示图片路径图片为.dat格式
gif_path string 如果当前收到的是gif表情,则会显示gif路径
file_path string 如果当前收到的是文件,则会显示文件路径
video_path string 如果当前收到的是视频,则会显示视频路径
voip_data string 如果当前收到的是语音,则会显示语音数据。格式为16进制文本的.silk文件
revoke_msg string 如果当前收到的是撤回的消息,则会显示撤回的内容
appletcode string 返回小程序code,如果调用了GetMiniAppCode_Sync接口则会返回该数据

msgtype 消息类型代码 二级代码参考:

1 文本消息 3 图片消息 34 语音消息 37 好友确认消息 40 好友推荐消息 42 共享名片 43 视频消息 44 主动撤回 47 动画表情 48 位置消息 49 APP分享链接/文件 50 VOIP消息 51 微信初始化消息 52 VOIP结束消息 53 VOIP邀请 62 小视频 9999 SYSNOTICE 10000 系统消息 10002 撤回消息

返回值

返回值将被忽略

Python FLASK 代码示例

获取聊天信息

# encoding:utf-8
from flask import Flask, request, jsonify
from flask_cors import CORS
import logging
from flask_httpauth import HTTPTokenAuth
import requests
import json
import binascii
import os
import sys
import logging
import re
from PIL import Image
import blackboxprotobuf

auth = HTTPTokenAuth(scheme='JWT')
app = Flask(__name__)

log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

# 获取聊天信息
@app.route('/api/user/recive_msg', methods=["POST"])
def recive_msg():

    if request.method == 'POST':

        print('=====================================')

        businesstype = request.json.get('businesstype')
        print('[业务类型URL]', businesstype)

        businessdata = request.json.get('businessdata')
        print('[业务数据]', businessdata)

        # 消息时间
        time = request.json.get('time')
        print('[消息时间]', time)

        # 消息类型
        msgtype = request.json.get('msgtype')
        print('[消息类型]', msgtype)

        # 设备代码
        device = request.json.get('device')
        print('[设备代码]', device)

        # 发送人微信ID
        fromwxid = request.json.get('fromwxid')
        print('[消息来源]', fromwxid)

        # 接收方微信ID/群ID
        toid = request.json.get('toid')
        print('[消息接收者]', toid)

        # 消息内容
        msg = request.json.get('msg')
        print('[消息内容]', msg)

        return '1'

    else:
        # 请求方式错误
        return '0'

# 获取语音信息
@app.route('/api/user/voip_msg', methods=["POST"])
def voip_msg():

    if request.method == 'POST':

        print('=====================================')

        # 消息类型
        msgtype = request.json.get('msgtype')
        print('[消息类型]', msgtype)

        # 消息内容
        msg = request.json.get('msg')
        print('[消息内容]', msg)

        return '1'

    else:
        # 请求方式错误
        return '0'

# 获取撤回的信息
@app.route('/api/user/revoke_msg', methods=["POST"])
def revoke_msg():

    if request.method == 'POST':

        print('=====================================')

        # 消息类型
        msgtype = request.json.get('msgtype')
        print('[消息类型]', msgtype)

        # 微信ID
        wxid = request.json.get('wxid')
        print('[微信ID]', wxid)

        # 撤回的消息内容
        revokemsg = request.json.get('revokemsg')
        print('[消息内容]', revokemsg)

        return '1'

    else:
        # 请求方式错误
        return '0'

# 获取好友和群信息清单
def GetFriendAndChatRoomList() -> str:
    url = "http://localhost:30001/GetFriendAndChatRoomList"
    aheaders = {'Content-Type': 'application/json'}

    r = requests.post(url, headers=aheaders)
    ret = r.text
    # print(ret)

# 发送文本消息
def SendTextMsg(wxid,msg) -> str:
    url = "http://localhost:30001/SendTextMsg"
    aheaders = {'Content-Type': 'application/json'}
    params_1 = {
            "wxid": wxid,
            "msg": msg,
    }

    data = json.dumps(params_1)
    #print('[JSON格式raw]', data)

    r = requests.post(url, headers=aheaders, data=data)
    ret = r.text
    print(ret)

# 刷新二维码
def RefreshLoginQRCode() -> str:
    url = "http://localhost:30001/RefreshLoginQRCode"
    aheaders = {'Content-Type': 'application/json'}

    r = requests.post(url, headers=aheaders)
    ret = r.text
    print(ret)

# 获取二维码图片
def GetLoginQRCode() -> str:
    url = "http://localhost:30001/GetLoginQRCode"
    aheaders = {'Content-Type': 'application/json'}

    r = requests.post(url, headers=aheaders)
    ret = r.text
    ret = json.loads(ret)
    ret = ret["hex_data"]
    data = binascii.a2b_hex(ret)

    # 保存为PNG
    file_name = "C:\\1.PNG"
    file = open(file_name, "wb")
    file.write(data)
    file.flush()
    file.close()

    # 保存为JPG
    file_name_2 = "C:\\1.JPG"
    im = Image.open(file_name)
    im = im.convert('RGB')
    im.save(file_name_2, quality=95)

    return '0'

# 自定义消息接受URL地址
def ConfigureMsgReciveFullURL(diyurl) -> str:
    url = "http://localhost:30001/ConfigureMsgReciveFullURL"

    aheaders = {'Content-Type': 'application/json'}
    params_1 = {
            "url": diyurl
    }

    data = json.dumps(params_1)
    #print('[JSON格式raw]', data)

    r = requests.post(url, headers=aheaders, data=data)
    ret = r.text
    print(ret)

# 开启消息接收功能
def ConfigureMsgRecive():

    url = "http://127.0.0.1:30001/ConfigureMsgRecive"
    aheaders = {'Content-Type': 'application/json'}
    params_1 = {
        "isEnable": "1"
    }
    data = json.dumps(params_1)
    #print('[JSON格式raw]', data)

    r = requests.post(url, headers=aheaders, data=data)
    ret = r.text
    print(ret)

# 开启图片自动下载
def AnywhereDownPicOrFile():
    url = "http://127.0.0.1:30001/AnywhereDownPicOrFile"
    aheaders = {'Content-Type': 'application/json'}

    r = requests.post(url, headers=aheaders)
    ret = r.text
    print(ret)

# 自定义URL获取聊天信息
i = 0
@app.route('/api/msg/recive', methods=["POST"])
def diy_recive_msg():

    if request.method == 'POST':
        payload = request.get_data(as_text=True)
        # print('[全数据]\r', payload)

        # 按照顺序打印输出
        payload = json.dumps(payload, sort_keys=True, indent=2, ensure_ascii=False)
        print('[全数据]\r', payload)
        # global i
        # i = i + 1

        # selfwxid = request.json.get('selfwxid')
        # appletcode = request.json.get('appletcode')
        # print(i, '[小程序Code]', selfwxid, appletcode)

        return '1'

        print('================= [自定义URL消息接收] ====================')
        ServerPort = request.json.get('ServerPort')
        # print('[服务端口]', ServerPort)

        selfwxid = request.json.get('selfwxid')
        # print('[本人微信ID]', selfwxid)

        # 1=收到的消息 2=发送的消息
        sendorrecv = request.json.get('sendorrecv')
        # print('[收发类型]', sendorrecv)

        # 本次收到消息的数量
        recvnumber = request.json.get('recvnumber')
        print('[收到数量]', recvnumber)

        # 消息类型
        msgtype = request.json.get('msgtype')
        print('[消息类型]', msgtype)

        businesstype = request.json.get('businesstype')
        # print('[业务类型URL]', businesstype)

        # businessdata = request.json.get('businessdata')
        # print('[业务数据]', businessdata)

        # businessdata = binascii.unhexlify(businessdata)
        # deserialize_data, message_type = blackboxprotobuf.protobuf_to_json(businessdata)

        # print('[非序列化]', deserialize_data)  # 非序列化的原始数据
        # print('[消息类型结构]', message_type)  # 消息类型结构
        # deserialize_data, message_type = blackboxprotobuf.decode_message(businessdata)
        # print('[解码后]', deserialize_data)

        # 消息时间
        time = request.json.get('time')
        print('[消息时间]', time)

        # 设备代码
        device = request.json.get('device')
        print('[设备代码]', device)

        # 发送人微信ID
        fromwxid = request.json.get('fromwxid')
        print('[发送人微信ID]', fromwxid)

        fromnickname = request.json.get('fromnickname')
        print('[发送人昵称]', fromnickname)

        fromname = request.json.get('fromname')
        print('[发送人备注名]', fromname)

        fromhead = request.json.get('fromhead')
        print('[发送人头像]', fromhead)

        # 接收方微信ID/群ID
        toid = request.json.get('toid')
        print('[消息接收者]', toid)

        tonickname = request.json.get('tonickname')
        print('[接收人昵称]', tonickname)

        toname = request.json.get('toname')
        print('[接收人备注名]', toname)

        tohead = request.json.get('tohead')
        print('[接收人头像]', tohead)

        # 消息内容
        msg = request.json.get('msg')
        print('[消息内容]', msg)

        msgid = request.json.get('msgid')
        print('[服务器消息ID]', msgid)

        # 图片路径(如果是图片消息的话)
        img_path = request.json.get('img_path')
        print('[图片路径]', img_path)

        # GIF动图路径
        img_path = request.json.get('gif_path')
        print('[动图路径]', img_path)

        # 文件路径
        img_path = request.json.get('file_path')
        print('[文件路径]', img_path)

        return '1'

    else:
        # 请求方式错误
        return '0'

# 创建目录
def mkdir(path):
    # 去除首位空格
    path = path.strip()
    # 去除尾部 \ 符号
    path = path.rstrip("\\")

    # 判断路径是否存在
    # 存在     True
    # 不存在   False
    isExists = os.path.exists(path)

    # 判断结果
    if not isExists:
        # 如果不存在则创建目录
        os.makedirs(path)

        #print(path + ' 创建成功')
        return True
    else:
        # 如果目录存在则不创建,并提示目录已存在
        #print(path + ' 目录已存在')
        return False

if __name__ == '__main__':

    # 单点功能测试
    # RefreshLoginQRCode()
    # GetLoginQRCode()

    # 获取好友和群清单
    # GetFriendAndChatRoomList()

    # 下面的代码是消息接收的部分
    app.config['JSON_AS_ASCII'] = False
    CORS(app, supports_credentials=True)

    # 自定义消息接收URL
    ConfigureMsgReciveFullURL("http://localhost:1026/api/msg/recive")

    # 开启消息接收
    ConfigureMsgRecive()

    # 开启任意时间段下载
    # AnywhereDownPicOrFile()

    app.run(host='0.0.0.0', port=1026, debug=True)

页面列表

ITEM_HTML