第三方应用开发 服务端API 数据分析专区 专区接口 拉取消息
拉取消息
最后更新:2024/01/22
可联系渠道经理采购或代理智慧硬件接口已支持设备 联系渠道经理
拉取消息
最后更新:2024/01/22

目录

  • 拉取任务消息
  • 消息明文格式
  •       公共字段定义
  •             用户信息UserInfo
  •       文本
  •       图片
  •       表情
  •       链接
  •       小程序
  •       语音
  •       视频
  •       文件
  •       名片
  •       转发消息
  •       视频号
  •       日程
  •       红包
  •       地理位置
  •       快速会议
  •       待办
  •       投票
  •       在线文档
  •       图文消息
  •       图文混合消息
  •       音频存档
  •       音视频通话
  •       微盘文件
  •       同意会话存档
  •       拒绝会话存档
  • 拉取任务消息

    通过jobid分页拉取消息明文。

    请求方式: POST(HTTPS
    请求地址: https://specapi.weixin.qq.com/spec/fetch_msg?access_token=ACCESS_TOKEN

    {
    	"jobid": "aaaabbbccc",
    	"limit": 100,
    	"cursor": "aaaaaaaaaaaa"
    }

    参数说明:

    参数必须类型说明
    access_tokenstring数据分析专区专用接口凭证
    jobidstring任务ID
    limitint限制每页数据最多返回多少条消息,默认值100,最大值100
    cursorstring上一次调用时返回的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": {
    				...
    			}
    		}
    	]
    }

    参数说明:

    参数类型说明
    errcodeint错误码
    errmsgstring错误描述
    has_morebool是否还有更多消息
    next_cursorstring当has_more=true时有值,在下一次请求时传入
    msg_listobject[]消息明文列表
    msgidstring每条消息对应的msgid
    sender.typeint消息发送者身份类型。1:员工;2:客户; 3:机器人
    sender.idstring消息发送者的id,当消息发送者为员工时,该字段为员工的open_userid;当消息发送者的身份为客户时,该字段为客户的id
    chatidstring群ID,当消息是群消息的时候会返回该字段
    receiver_list.typeint消息接受者的身份类型。1:员工;2:客户; 3:机器人
    receiver_list.idstring当接收者身份类型为员工时,该字段为员工open_userid;当接收者身份类型为客户时,该字段为客户id;当接收者身份类型为机器人式为机器人ID
    send_timeint消息发送时间对应的unix时间戳
    msgtypeint消息类型。枚举值定义见获取会话记录-消息类型
    is_recalledbool消息是否被撤回,如果为true不会返回消息原文

     

    消息明文格式

    公共字段定义

    用户信息UserInfo

    {
    	"type": 1,
    	"id": "xxxxx"
    }
    参数类型说明
    typeintid类型,1:open_userid,2:external_userid
    idstring用户的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"
    					}
    				}
    			}
    		]
    	}
    }
    参数类型说明
    msgtypeint文本消息固定为1
    textobject文本消息内容
    text.itemsobject[]
    text.items[].typeint消息类型。1:文本消息,2:@用户消息
    text.items[].textobject
    text.items[].text.contentstring文本消息内容
    text.items[].text.is_emotionbool是否是系统表情。如果是系统表情,content内容是"[高兴]"这样的样式。
    text.items[].atobject 
    text.items[].at.is_at_allbool是否@所有人
    text.items[].at.userUserInfo@用户内容,如果is_at_all为true,则该字段为空

    图片

    {
    	"msgtype": 2,
    	"image": {
    		"media_id": "MEIDA_ID",
    		"size": 10000
    	}
    }
    参数类型说明
    msgtypeint图片消息固定为2
    imageobject图片消息
    image.media_idstring图片素材id
    image.sizeint图片大小

    表情

    {
    	"msgtype": 3,
    	"emotion": {
    		"url": "URL"
    	}
    }
    参数类型说明
    msgtypeint表情消息固定为3
    emotionobject表情消息
    emotion.urlstring表情url

    链接

    {
    	"msgtype": 4,
    	"link": {
    		"title": "TITLE",
    		"description: "DESCRIPTION",
    		"link_url": "http://www.qq.com",
    		"image_url": "URL"
    	}
    }
    参数类型说明
    msgtypeint链接消息固定为4
    linkobject链接消息
    link.titlestring链接标题
    link.descriptionstring链接描述
    link.link_urlstring链接url
    link.image_urlstring链接图片url

    小程序

    {
    	"msgtype": 5,
    	"mini_program": {
    		"username": "USERNAME",
    		"icon_url": "URL",
    		"displayname": "DISPLAYNAME",
    		"title": "TITLE",
    		"description": "DESCRIPTION"
    	}
    }
    参数类型说明
    msgtypeint链接消息固定为5
    mini_programobject小程序消息
    mini_program.usernamestring用户名称
    mini_program.icon_urlstring小程序头像url
    mini_program.displaynamestring小程序名称
    mini_program.titlestring消息标题
    mini_program.descriptionstring小程序描述

    语音

    {
    	"msgtype": 6,
    	"voice": {
    		"media_id": "MEDIA_ID",
    		"size": 2000,
    		"playtime": 1000
    	}
    }
    参数类型说明
    msgtypeint语音消息固定为6
    voiceobject语音消息
    voice.media_idstring语音素材id
    voice.sizeint语音大小
    voice.playtimeint语音时长

    视频

    {
    	"msgtype": "video",
    	"video": {
    		"media_id": "MEDIA_ID",
    		"size": 2000,
    		"playtime": 1000
    	}
    }
    参数类型说明
    msgtypeint视频消息固定为7
    videoobject视频消息
    video.media_idstring视频素材id
    video.sizeint视频大小
    video.playtimeint视频时长

    文件

    {
    	"msgtype": 8,
    	"file": {
    		"media_id": "MEDIA_ID",
    		"filename": "FILENAME",
    		"size": SIZE
    	}
    }
    参数类型说明
    msgtypeint文件消息固定为8
    fileobject文件消息
    file.media_idstring文件素材id
    file.filenamestring文件名
    file.sizeint文件大小

     

    名片

    {
    	"msgtype": 9,
    	"card": {
    		"user": {
    			"type": 1,
    			"id": "aaaaaaaa"
    		},
    		"corp_name": "zzzzzz",
    	}
    }
    参数类型说明
    msgtypeint名片消息固定为9
    cardobject名片消息
    card.userUserInfo名片所有者信息
    card.corp_namestring名片所有者所在企业名称

    转发消息

    {
    	"msgtype": 10,
    	"forward": {
    		"source": {
    			"chattype": 1,
    			"user_list": [
    				{
    					"type": 1,
    					"id": "xxxxx"
    				}
    			]
    		}
    		"items": [
    			{
    				"msgtype": 1,
    				"text": {
    					...
    				}
    			},
    			{
    				"msgtype": 2,
    				"image": {
    					...
    				}
    			}
    		]
    	}
    }
    参数类型说明
    msgtypeint转发消息固定为10
    forwardobject转发消息
    forward.sourceobject转发消息来源
    forward.source.chattypeint来源类型,1:单聊,2:群聊
    forward.source.userUserInfo[]单聊时会话双方的id
    forward.itemsobject[]转发消息内容,通过msgtype判断消息类型,items中其他字段参考本篇文档不同消息类型中的字段说明
    forward.items[].msgtypeint消息类型。枚举值定义见获取会话记录-消息类型,仅限1:文本,2:图片,3:表情,4:链接,5:小程序,7:视频,8:文件,10:转发消息,14:地理位置

    视频号

    {
    	"msgtype": 11,
    	"channel": {
    		"feedtype": 1,
    		"name": "aaaaaaaa"
    		"description": "zzzzzz",
    	}
    }
    参数类型说明
    msgtypeint视频号消息固定为11
    channelobject视频号消息
    channel.feedtypeint视频号消息类型,1:图片,2:视频,3:直播
    channel.namestring视频号账号名称
    channel.descriptionstring视频号消息描述

    日程

    {
    	"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"
    	}
    }
    参数类型说明
    msgtypeint日程消息固定为12
    scheduleobject日程消息
    schedule.typeint日程类型,1:普通日程,2:会议
    schedule.titlestring日程主题
    schedule.creatorUserInfo日程组织者
    schedule.attendee_listUserInfo[]日程参与人
    schedule.starttimeint日程开始时间
    schedule.endtimeint日程结束时间
    schedule.placestring日程地点
    schedule.remarksstring日程备注

    红包

    {
    	"msgtype": 13,
    	"redpacket": {
    		"type": 1,
    		"wish": "WISH",
    		"totalcnt": 10,
    		"totalamount": 10
    	}
    }
    参数类型说明
    msgtypeint红包消息固定为13
    redpacketobject红包消息
    redpacket.typeint红包消息类型,1:普通红包,2:拼手气群红包,3:激励群红包
    redpacket.wishstring红包祝福语
    redpacket.totalcntint红包总个数
    redpacket.totalamountint64红包总金额,单位为分

    地理位置

    {
    	"msgtype": 14,
    	"location": {
    		"longtitude": 14.5
    		"latitude": 20.4,
    		"title": "TITLE",
    		"address": "ADDRESS"
    	}
    }
    参数类型说明
    msgtypeint地理位置消息固定为14
    locationobject地理位置消息
    location.longtitudedouble经度
    location.latitudedouble纬度
    location.titlestring消息标题
    location.addressstring地址

    快速会议

    {
    	"msgtype": 15,
    	"quick_meeting": {
    		"title": "TITLE",
    		"creator": {
    			"type": 1,
    			"id": "xxxxx"
    		}
    	}
    }
    参数类型说明
    msgtypeint快速会议消息固定为15
    quick_meetingobject快速会议消息
    quick_meeting.titlestring消息标题
    quick_meeting.creatorUserInfo会议创建者

     

    待办

    {
    	"msgtype": 16,
    	"todo": {
    		"title": "TITLE",
    		"content": "CONTENT"
    	}
    }
    参数类型说明
    msgtypeint待办消息固定为16
    todoobject待办消息
    todo.titlestring待办的来源文本
    todo.contentstring待办的具体内容

    投票

    {
    	"msgtype": 17,
    	"vote": {
    		"oper_type": 1
    		"title": "TITLE",
    		"creator": {
    			"type": 1,
    			"id": "xxxxxx"
    		},
    		"vote_items": [
    			{
    				"itemid": 123,
    				"itemname": "ITEMNAME"
    			}
    		]
    	}
    }
    参数类型说明
    msgtypeint投票消息固定为17
    voteobject投票消息
    vote.titlestring投票主题
    vote.oper_typeint操作类型,1:发送投票消息,2:参与投票
    vote.creatorUserInfo投票创建者信息
    vote.vote_itemsobject[]投票选项
    vote.vote_items[].itemidint投票选项id
    vote.vote_items[].itemnamestring投票选项名称

    在线文档

    {
    	"msgtype": 18,
    	"doc": {
    		"title": "TITLE",
    		"link_url": "URL",
    		"creator": {
    			"type": 1,
    			"id": "xxxxxx"
    		}
    	}
    }
    参数类型说明
    msgtypeint在线文档消息固定为18
    docobject在线文档消息
    doc.titlestring在线文档名称
    doc.link_urlstring在线文档链接
    doc.creatorUserInfo在线文档创建者信息

    图文消息

    {
    	"msgtype": 19,
    	"news": {
    		"items": [
    			{
    				"title": "TITLE",
    				"description": "DESCRIPTION",
    				"url": "URL",
    				"pic_url": "PIC_URL"
    			}
    		]
    	}
    }
    参数类型说明
    msgtypeint图文消息固定为19
    newsobject图文消息信息
    news.titlestring图文消息标题
    news.descriptionstring图文消息描述
    news.urlstring图文消息点击跳转地址
    news.pic_urlstring图文消息图片地址

    图文混合消息

    {
    	"msgtype": 20,
    	"mixed": {
    		"items": [
    			{
    				"msgtype": 1,
    				"text": {
    					...
    				}
    			},
    			{
    				"msgtype": 2,
    				"image": {
    					...
    				}
    			},
    			{
    				"msgtype": 3,
    				"emotion": {
    					...
    				}
    			}
    		]
    	}
    }
    参数类型说明
    msgtypeint图文混合消息固定为20
    mixedobject图文混合消息信息,可包含图片、文字、表情等多种消息
    mixed.itemsobject[]
    mixed.items[].msgtypeint消息类型,1:文字,2:图片,3:表情

    音频存档

    {
    	"msgtype": 21,
    	"meeting_voice": {
    		"creator": {
    			"type": 1,
    			"id": "xxxxxx"
    		},
    		"starttime": 123456,
    		"endtime": 234567,
    		"voice": {
    			"media_id": "xxxxx",
    			"size": 10000,
    			"playtime": 1000
    		}
    	}
    }
    参数类型说明
    msgtypeint音频存档消息固定为21
    meeting_voiceobject音频存档消息
    meeting_voice.creatorUserInfo音频存档创建者信息
    meeting_voice.starttimeint音频存档开始时间
    meeting_voice.endtimeint音频存档结束时间
    meeting_voice.voiceobject音频信息
    meeting_voice.voice.media_idstring音频素材id
    meeting_voice.voice.sizeint音频大小
    meeting_voice.voice.playtimeint音频时长

    音视频通话

    {
    	"msgtype": 22,
    	"voiptext": {
    		"call_duration": 60,
    		"invite_type": 1,
    		"record_type": 1
    	}
    }
    参数类型说明
    msgtypeint音视频通话消息固定为22
    voiptextobject音视频通话消息信息
    voiptext.call_durationint通话时长,单位为秒
    voiptext.invite_typeint通话类型,1:视频通话,2:语音通话,3:多人视频通话,4:多人语音通话
    voiptext.record_typeint操作类型,1:取消通话,2:拒绝通话,3:未接听通话,4:接受通话,5:结束通话

    微盘文件

    {
    	"msgtype": 23,
    	"wedrive_file": {
    		"filename": "NAME",
    		"size": 20000
    	}
    }
    参数类型说明
    msgtypeint微盘文件消息固定为23
    wedrive_fileobject微盘文件消息信息
    wedrive_file.filenamestring微盘文件名
    wedrive_file.sizeint文件大小

    同意会话存档

    {
    	"msgtype": 24,
    	"agree": {
    		"agree_time": 123456
    	}
    }
    参数类型说明
    msgtypeint同意会话存档消息固定为24
    agreeobject同意会话存档消息
    agree.agree_timeint同意时间

    拒绝会话存档

    {
    	"msgtype": 25,
    	"disagree": {
    		"disagree_time": 123456
    	}
    }
    参数类型说明
    msgtypeint拒绝会话存档消息固定为25
    disagreeobject拒绝会话存档消息
    disagree.disagree_timeint拒绝时间
    上一篇
    执行任务以及上报进度或结果
    下一篇
    下载消息素材