目录
拉取任务消息消息明文格式 公共字段定义 用户信息UserInfo 文本 图片 表情 链接 小程序 语音 视频 文件 名片 转发消息 视频号 日程 红包 地理位置 快速会议 待办 投票 在线文档 图文消息 图文混合消息 音频存档 音视频通话 微盘文件 同意会话存档 拒绝会话存档拉取任务消息
通过jobid分页拉取消息明文。
请求方式: POST(HTTPS)
请求地址: https://specapi.weixin.qq.com/spec/fetch_msg?access_token=ACCESS_TOKEN
{
"jobid": "aaaabbbccc",
"limit": 100,
"cursor": "aaaaaaaaaaaa"
}
参数说明:
参数 | 必须 | 类型 | 说明 |
---|
access_token | 是 | string | 数据分析专区专用接口凭证 |
jobid | 是 | string | 任务ID |
limit | 否 | int | 限制每页数据最多返回多少条消息,默认值100,最大值100 |
cursor | 否 | string | 上一次调用时返回的next_cursor,第一次拉取可以不填。不多于64字节 |
权限说明:
- 需要使用pod专用access_token
- 只有进行中任务才能拉取消息
请求回包
{
"errcode":0,
"errmsg":"ok",
"has_more": true,
"next_cursor": "ababababababab",
"msg_list":[
{
"msgid":"xxxmsgid",
"sender":{
"type":1,
"id":"woxxxxxmmgjiegjie"
},
"receiver_list": [
{
"type": 1,
"id": "woAAAAAAAAAAA"
},
{
"type": 2,
"id": "wmXXXXXXXXXXXXX"
}
],
"chatid": "wrXXXXXXXXXX",
"send_time":166666666,
"is_recalled": false,
"msgtype":2,
"text": {
...
}
}
]
}
参数说明:
参数 | 类型 | 说明 |
---|
errcode | int | 错误码 |
errmsg | string | 错误描述 |
has_more | bool | 是否还有更多消息 |
next_cursor | string | 当has_more=true时有值,在下一次请求时传入 |
msg_list | object[] | 消息明文列表 |
msgid | string | 每条消息对应的msgid |
sender.type | int | 消息发送者身份类型。1:员工;2:客户; 3:机器人 |
sender.id | string | 消息发送者的id,当消息发送者为员工时,该字段为员工的open_userid;当消息发送者的身份为客户时,该字段为客户的id |
chatid | string | 群ID,当消息是群消息的时候会返回该字段 |
receiver_list.type | int | 消息接受者的身份类型。1:员工;2:客户; 3:机器人 |
receiver_list.id | string | 当接收者身份类型为员工时,该字段为员工open_userid;当接收者身份类型为客户时,该字段为客户id;当接收者身份类型为机器人式为机器人ID |
send_time | int | 消息发送时间对应的unix时间戳 |
msgtype | int | 消息类型。枚举值定义见获取会话记录-消息类型 |
is_recalled | bool | 消息是否被撤回,如果为true不会返回消息原文 |
消息明文格式
公共字段定义
用户信息UserInfo
{
"type": 1,
"id": "xxxxx"
}
参数 | 类型 | 说明 |
---|
type | int | id类型,1:open_userid,2:external_userid |
id | string | 用户的id |
文本
{
"msgtype": 1,
"text": {
"items": [
{
"type": 1,
"text": {
"content": "xxxxx",
"is_emotion": false,
}
},
{
"type": 2,
"at": {
"is_at_all": false,
"user": {
"type": 1,
"id": "yyyyyy"
}
}
}
]
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 文本消息固定为1 |
text | object | 文本消息内容 |
text.items | object[] | |
text.items[].type | int | 消息类型。1:文本消息,2:@用户消息 |
text.items[].text | object | |
text.items[].text.content | string | 文本消息内容 |
text.items[].text.is_emotion | bool | 是否是系统表情。如果是系统表情,content内容是"[高兴]"这样的样式。 |
text.items[].at | object | |
text.items[].at.is_at_all | bool | 是否@所有人 |
text.items[].at.user | UserInfo | @用户内容,如果is_at_all为true,则该字段为空 |
图片
{
"msgtype": 2,
"image": {
"media_id": "MEIDA_ID",
"size": 10000
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 图片消息固定为2 |
image | object | 图片消息 |
image.media_id | string | 图片素材id |
image.size | int | 图片大小 |
表情
{
"msgtype": 3,
"emotion": {
"url": "URL"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 表情消息固定为3 |
emotion | object | 表情消息 |
emotion.url | string | 表情url |
链接
{
"msgtype": 4,
"link": {
"title": "TITLE",
"description: "DESCRIPTION",
"link_url": "http://www.qq.com",
"image_url": "URL"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 链接消息固定为4 |
link | object | 链接消息 |
link.title | string | 链接标题 |
link.description | string | 链接描述 |
link.link_url | string | 链接url |
link.image_url | string | 链接图片url |
小程序
{
"msgtype": 5,
"mini_program": {
"username": "USERNAME",
"icon_url": "URL",
"displayname": "DISPLAYNAME",
"title": "TITLE",
"description": "DESCRIPTION"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 链接消息固定为5 |
mini_program | object | 小程序消息 |
mini_program.username | string | 用户名称 |
mini_program.icon_url | string | 小程序头像url |
mini_program.displayname | string | 小程序名称 |
mini_program.title | string | 消息标题 |
mini_program.description | string | 小程序描述 |
语音
{
"msgtype": 6,
"voice": {
"media_id": "MEDIA_ID",
"size": 2000,
"playtime": 1000
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 语音消息固定为6 |
voice | object | 语音消息 |
voice.media_id | string | 语音素材id |
voice.size | int | 语音大小 |
voice.playtime | int | 语音时长 |
视频
{
"msgtype": "video",
"video": {
"media_id": "MEDIA_ID",
"size": 2000,
"playtime": 1000
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 视频消息固定为7 |
video | object | 视频消息 |
video.media_id | string | 视频素材id |
video.size | int | 视频大小 |
video.playtime | int | 视频时长 |
文件
{
"msgtype": 8,
"file": {
"media_id": "MEDIA_ID",
"filename": "FILENAME",
"size": SIZE
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 文件消息固定为8 |
file | object | 文件消息 |
file.media_id | string | 文件素材id |
file.filename | string | 文件名 |
file.size | int | 文件大小 |
名片
{
"msgtype": 9,
"card": {
"user": {
"type": 1,
"id": "aaaaaaaa"
},
"corp_name": "zzzzzz",
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 名片消息固定为9 |
card | object | 名片消息 |
card.user | UserInfo | 名片所有者信息 |
card.corp_name | string | 名片所有者所在企业名称 |
转发消息
{
"msgtype": 10,
"forward": {
"source": {
"chattype": 1,
"user_list": [
{
"type": 1,
"id": "xxxxx"
}
]
}
"items": [
{
"msgtype": 1,
"text": {
...
}
},
{
"msgtype": 2,
"image": {
...
}
}
]
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 转发消息固定为10 |
forward | object | 转发消息 |
forward.source | object | 转发消息来源 |
forward.source.chattype | int | 来源类型,1:单聊,2:群聊 |
forward.source.user | UserInfo[] | 单聊时会话双方的id |
forward.items | object[] | 转发消息内容,通过msgtype判断消息类型,items中其他字段参考本篇文档不同消息类型中的字段说明 |
forward.items[].msgtype | int | 消息类型。枚举值定义见获取会话记录-消息类型,仅限1:文本,2:图片,3:表情,4:链接,5:小程序,7:视频,8:文件,10:转发消息,14:地理位置 |
视频号
{
"msgtype": 11,
"channel": {
"feedtype": 1,
"name": "aaaaaaaa"
"description": "zzzzzz",
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 视频号消息固定为11 |
channel | object | 视频号消息 |
channel.feedtype | int | 视频号消息类型,1:图片,2:视频,3:直播 |
channel.name | string | 视频号账号名称 |
channel.description | string | 视频号消息描述 |
日程
{
"msgtype": 12,
"schedule": {
"type": 1,
"title": "TITLE",
"creator": {
"type": 1,
"id": "XXXXX"
},
"attendee_list": [
{
"type": 1,
"id": "XXXX"
}
],
"starttime": 123456,
"endtime": 234567,
"place": "PLACE",
"remarks": "REMARKS"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 日程消息固定为12 |
schedule | object | 日程消息 |
schedule.type | int | 日程类型,1:普通日程,2:会议 |
schedule.title | string | 日程主题 |
schedule.creator | UserInfo | 日程组织者 |
schedule.attendee_list | UserInfo[] | 日程参与人 |
schedule.starttime | int | 日程开始时间 |
schedule.endtime | int | 日程结束时间 |
schedule.place | string | 日程地点 |
schedule.remarks | string | 日程备注 |
红包
{
"msgtype": 13,
"redpacket": {
"type": 1,
"wish": "WISH",
"totalcnt": 10,
"totalamount": 10
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 红包消息固定为13 |
redpacket | object | 红包消息 |
redpacket.type | int | 红包消息类型,1:普通红包,2:拼手气群红包,3:激励群红包 |
redpacket.wish | string | 红包祝福语 |
redpacket.totalcnt | int | 红包总个数 |
redpacket.totalamount | int64 | 红包总金额,单位为分 |
地理位置
{
"msgtype": 14,
"location": {
"longtitude": 14.5
"latitude": 20.4,
"title": "TITLE",
"address": "ADDRESS"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 地理位置消息固定为14 |
location | object | 地理位置消息 |
location.longtitude | double | 经度 |
location.latitude | double | 纬度 |
location.title | string | 消息标题 |
location.address | string | 地址 |
快速会议
{
"msgtype": 15,
"quick_meeting": {
"title": "TITLE",
"creator": {
"type": 1,
"id": "xxxxx"
}
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 快速会议消息固定为15 |
quick_meeting | object | 快速会议消息 |
quick_meeting.title | string | 消息标题 |
quick_meeting.creator | UserInfo | 会议创建者 |
待办
{
"msgtype": 16,
"todo": {
"title": "TITLE",
"content": "CONTENT"
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 待办消息固定为16 |
todo | object | 待办消息 |
todo.title | string | 待办的来源文本 |
todo.content | string | 待办的具体内容 |
投票
{
"msgtype": 17,
"vote": {
"oper_type": 1
"title": "TITLE",
"creator": {
"type": 1,
"id": "xxxxxx"
},
"vote_items": [
{
"itemid": 123,
"itemname": "ITEMNAME"
}
]
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 投票消息固定为17 |
vote | object | 投票消息 |
vote.title | string | 投票主题 |
vote.oper_type | int | 操作类型,1:发送投票消息,2:参与投票 |
vote.creator | UserInfo | 投票创建者信息 |
vote.vote_items | object[] | 投票选项 |
vote.vote_items[].itemid | int | 投票选项id |
vote.vote_items[].itemname | string | 投票选项名称 |
在线文档
{
"msgtype": 18,
"doc": {
"title": "TITLE",
"link_url": "URL",
"creator": {
"type": 1,
"id": "xxxxxx"
}
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 在线文档消息固定为18 |
doc | object | 在线文档消息 |
doc.title | string | 在线文档名称 |
doc.link_url | string | 在线文档链接 |
doc.creator | UserInfo | 在线文档创建者信息 |
图文消息
{
"msgtype": 19,
"news": {
"items": [
{
"title": "TITLE",
"description": "DESCRIPTION",
"url": "URL",
"pic_url": "PIC_URL"
}
]
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 图文消息固定为19 |
news | object | 图文消息信息 |
news.title | string | 图文消息标题 |
news.description | string | 图文消息描述 |
news.url | string | 图文消息点击跳转地址 |
news.pic_url | string | 图文消息图片地址 |
图文混合消息
{
"msgtype": 20,
"mixed": {
"items": [
{
"msgtype": 1,
"text": {
...
}
},
{
"msgtype": 2,
"image": {
...
}
},
{
"msgtype": 3,
"emotion": {
...
}
}
]
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 图文混合消息固定为20 |
mixed | object | 图文混合消息信息,可包含图片、文字、表情等多种消息 |
mixed.items | object[] | |
mixed.items[].msgtype | int | 消息类型,1:文字,2:图片,3:表情 |
音频存档
{
"msgtype": 21,
"meeting_voice": {
"creator": {
"type": 1,
"id": "xxxxxx"
},
"starttime": 123456,
"endtime": 234567,
"voice": {
"media_id": "xxxxx",
"size": 10000,
"playtime": 1000
}
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 音频存档消息固定为21 |
meeting_voice | object | 音频存档消息 |
meeting_voice.creator | UserInfo | 音频存档创建者信息 |
meeting_voice.starttime | int | 音频存档开始时间 |
meeting_voice.endtime | int | 音频存档结束时间 |
meeting_voice.voice | object | 音频信息 |
meeting_voice.voice.media_id | string | 音频素材id |
meeting_voice.voice.size | int | 音频大小 |
meeting_voice.voice.playtime | int | 音频时长 |
音视频通话
{
"msgtype": 22,
"voiptext": {
"call_duration": 60,
"invite_type": 1,
"record_type": 1
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 音视频通话消息固定为22 |
voiptext | object | 音视频通话消息信息 |
voiptext.call_duration | int | 通话时长,单位为秒 |
voiptext.invite_type | int | 通话类型,1:视频通话,2:语音通话,3:多人视频通话,4:多人语音通话 |
voiptext.record_type | int | 操作类型,1:取消通话,2:拒绝通话,3:未接听通话,4:接受通话,5:结束通话 |
微盘文件
{
"msgtype": 23,
"wedrive_file": {
"filename": "NAME",
"size": 20000
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 微盘文件消息固定为23 |
wedrive_file | object | 微盘文件消息信息 |
wedrive_file.filename | string | 微盘文件名 |
wedrive_file.size | int | 文件大小 |
同意会话存档
{
"msgtype": 24,
"agree": {
"agree_time": 123456
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 同意会话存档消息固定为24 |
agree | object | 同意会话存档消息 |
agree.agree_time | int | 同意时间 |
拒绝会话存档
{
"msgtype": 25,
"disagree": {
"disagree_time": 123456
}
}
参数 | 类型 | 说明 |
---|
msgtype | int | 拒绝会话存档消息固定为25 |
disagree | object | 拒绝会话存档消息 |
disagree.disagree_time | int | 拒绝时间 |