回调信息解析

私聊消息

参数名 类型 说明
seq number 序号
token string 微信sessionId
message object 消息内容
message.id number 消息id
message.remote_id String
message.text String 消息内容
message.timestamp String 时间戳
message.type String 消息类型 Text:文本 Image:图片Video:视频 Location:位置 Contact:名片MiniProgram:小程序 Url:链接
message.from_id String 发送人wxId
message.to_id String 接收人wxId

注意:不同类型的聊天消息,消息内容格式不一样,请根据实际返回内容进行处理

文本消息

{
    "seq": "9325976",
    "token": "2fe8b98609a94a2089786fd379ef2724",
    "message": {
        "id": 1000423,
        "remote_id": "9325976",
        "text": "文本",
        "timestamp": "1697612364",
        "type": "Text",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

图片消息

{
    "seq": "9326066",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000649,
        "remote_id": "9326066",
        "text": "{\"file_id\":\"30819302010204818b30818802010002044c9aff3e02030f42410204157a58750204652f8361044c4e45574944315f34633961666633653135376135383735363533306137333030303038396165395f30373431386365322d313064652d343034362d396365372d663931613938616132363335020100020302f2500410c9c4cb71e1f5566c91e70f67241ae6a30201020201000400\",\"wechat_cdn_ld_size\":0,\"file_name\":\"\",\"size\":\"193099\",\"width\":\"1242\",\"height\":\"2688\",\"aes_key\":\"7fd432140980ec5f43aa8ab96fedbbd4\",\"md5\":\"c9c4cb71e1f5566c91e70f67241ae6a3\"}",
        "timestamp": "1697687344",
        "type": "Image",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

视频消息

{
    "seq": "9326070",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000658,
        "remote_id": "9326070",
        "text": "{\"video_file_id\":\"30690201020462306002010002044c9aff3e02030f42410204bf79587502046530a768042436656637656661382d613031392d343762332d616264352d3062646639643730613534300201000203037e500410c62226ce08f05677f19e285b5a90e2ff0201040201000400\",\"video_size\":228936,\"video_play_time\":2,\"video_aes_key\":\"bfb661eea1fd4fbe8caa05291faee484\",\"video_md5\":\"c62226ce08f05677f19e285b5a90e2ff\",\"width\":1080,\"height\":1920,\"preface_image_url\":\"https://wework.qpic.cn/wwpic/874650_-iamzVVYSvK4k6I_1697687400\",\"url\":\"/var/mobile/Containers/Data/Application/14B9C89B-D63E-4D54-8105-8AC565A19F6B/Documents/Profiles/9B104E1611D848EA84047D3B6CCAD9C7/UploadFiles/7291191586600584076.MP4\",\"preface_image_size\":10415,\"wechat_auth_key\":\"\"}",
        "timestamp": "1697687401",
        "type": "Video",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

位置消息

{
    "seq": "9326072",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000663,
        "remote_id": "9326072",
        "text": "{\"zoom\":0.0,\"address\":\"***北(东环南路西)\",\"latitude\":\"14.687432\",\"longitude\":\"166.647677\",\"title\":\"***北(东环南路西)\"}",
        "timestamp": "1697687469",
        "type": "Location",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

名片消息

{
    "seq": "9326074",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000668,
        "remote_id": "9326074",
        "text": "1688856489464987",
        "timestamp": "1697687543",
        "type": "Contact",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

小程序消息

{
    "seq": "9326076",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000673,
        "remote_id": "9326076",
        "text": "{\"parameter\":{\"title\":\"一键生成高清电子文档,全球4亿用户都在用\",\"id\":\"wx10c0611db3c5b8d3\",\"user_name\":\"gh_f71e27dda6a0@app\",\"display_name\":\"扫描全能王+\",\"icon_url\":\"http://mmbiz.qpic.cn/mmbiz_png/AuRG2YExGWoyq9l8SOgxC0rcibGAPI8nbMkiaFKaJ4ZNmVRQQBKglibhz7E3CNO5y3CBbqGXHpZhK9E0BynJ76E5A/640?wx_fmt=png&wxfrom=200\",\"page_path\":\"pages/home/home.html\",\"room_todo_flag\":0},\"preface\":{\"file_id\":\"30680201020461305f02010002044c9aff3e02030f42410204b63066b40204652f85a8042430363266653062322d373964662d346235372d393062352d376166373934613462303631020100020258600410f253051b284bc26431fbdd2dae10320a0201010201000400\",\"raw_thumb_md5\":\"f253051b284bc26431fbdd2dae10320a\",\"thumb_total_size\":22619,\"aes_key\":\"19bcfe12381e4583bc8567dcbd7106a2\"}}",
        "timestamp": "1697687633",
        "type": "MiniProgram",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

链接消息

{
    "seq": "9326078",
    "token": "f63398ce70d44a529576eae7d181ce12",
    "message": {
        "id": 1000678,
        "remote_id": "9326078",
        "text": "{\"title\":\"啦啦啦啦啦\",\"desc\":\"噗噗噗噗噗\",\"url\":\"http://wwww.baidu.com\",\"thumb_url\":\"https://wework.qpic.cn/wwpic/690986_UjHzlJlNR3y7kq2_1685520972\"}",
        "timestamp": "1697687721",
        "type": "Url",
        "from_id": "1688****534",
        "to_id": "16888****798"
    }
}

群聊消息

参数名 类型 说明
seq number 序号
token string 微信sessionId
message object 消息内容
message.id number 消息id
message.remote_id String
message.text String 消息内容
message.timestamp String 时间戳
message.type String 消息类型 Text:文本 Image:图片 Video:视频 Location:位置 Contact:名片 MiniProgram:小程序 Url:链接
message.from_id String 发送人wxId
message.room_id String 群组id

注意:不同类型的聊天消息,消息内容格式不一样,请根据实际返回内容进行处理

示例

{
    "seq": "9326006",
    "token": "2fe8b98609a94a2089786fd379ef2724",
    "message": {
        "id": 1000492,
        "remote_id": "9326006",
        "text": "测试",
        "timestamp": "1697614321",
        "type": "Text",
        "from_id": "1688****534",
        "room_id": "10765992068360238"
    }
}

事件消息

功能 操作 代码
群相关 修改群名称 ROOM_TOPIC
加入群聊 ROOM_JOIN
移除群聊 ROOM_LEAVE
退出 退出微信 LOGOUT

修改群名

{
    "seq": "9326115",
    "token": "bfd9287644cb42d8b6db9d9d72d2c0e7",
    "event": {
        "event_type": "ROOM_TOPIC",
        "payload": {
            "changer_id": "1688855440457534",
            "new_topic": "测试群",
            "room_id": "R:10820914206954126",
            "timestamp": "1697698470000",
            "kind": "ROOM_TOPIC",
            "extension": "08c48a3d10a39cb904180120befeebe4948080032800308ea5cddb86b29c1338e9074209e6b58be8af95e7bea44a0477777778580060a6a5c3a906688080800870007a204141304141443530454331453434433542433936304536383530424133333734a20100a80100"
        }
    }
}

加入群聊

{
    "seq": "9326122",
    "token": "bfd9287644cb42d8b6db9d9d72d2c0e7",
    "event": {
        "event_type": "ROOM_JOIN",
        "payload": {
            "invitee_id_list": [
                "1688857997391344"
            ],
            "inviter_id": "1688855440457534",
            "room_id": "R:10820914206954126",
            "timestamp": "1697701029000",
            "kind": "ROOM_JOIN",
            "extension": "08d38a3d10aa9cb904180120befeebe4948080032800308ea5cddb86b29c1338ea074210313638383835373939373339313334344a0477777778580060a5b9c3a906688080800870007a18434151516f376e447151595941434338704e433743513d3da20100a80100"
        }
    }
}

移除群聊

{
    "seq": "9326127",
    "token": "bfd9287644cb42d8b6db9d9d72d2c0e7",
    "event": {
        "event_type": "ROOM_LEAVE",
        "payload": {
            "removee_id_list": [
                "1688855655434798"
            ],
            "remover_id": "1688855440457534",
            "room_id": "R:10820914206954126",
            "timestamp": "1697701185000",
            "kind": "ROOM_LEAVE",
            "extension": "08dd8a3d10af9cb904180120befeebe4948080032800308ea5cddb86b29c1338eb074210313638383835353635353433343739384a0477777778580060c1bac3a906688080800870007a1843415151774c7244715159594143434e7966615141673d3da20100a80100"
        }
    }
}

退出微信

{
    "seq": "0",
    "token": "bfd9287644cb42d8b6db9d9d72d2c0e7",
    "event": {
        "event_type": "LOGOUT",
        "payload": {
            "data": "手机端退出登录(65538)",
            "extension": "08f00710befeebe494808003823f0408828004"
        }
    }
}
Copyright © wkteam.cn 2020 all right reserved,powered by Gitbook该文件修订时间: 2023-12-16 17:29:42

results matching ""

    No results matching ""