友米聚合 - 开放API
  1. ChatMess
友米聚合 - 开放API
  • 应用场景
    • 自有订单系统 嵌入 企客聊侧边栏
  • v1
    • 文档
      • 介绍
        • 开发文档阅读说明
        • 错误码返回说明
      • 入门说明
        • 生成signature
        • 获取TOKEN方法
        • 请求Headers说明
      • 接口详情
        • 基础数据类接口
        • 数据读取类接口
        • 行为操作类接口
        • 回调数据
  • v2
    • 事件发布格式说明
    • ChatMess
      • 发送消息
        POST
      • 申请接管
        POST
      • 终止接管
        POST
      • 激活会话
        POST
      • 发送通知
        POST
      • 读取聊天记录
        POST
    • Report
      • 获取员工客服统计
      • 获取员工激活客户数统计
    • System
      • 获取部门列表
      • 根据部门获得组
      • 根据组获得员工
      • 获得员工列表
    • Friend
      • 读取粉丝列表
      • 读取粉丝总数
    • Todo
      • 新增待办记录
      • 新增待办记录(返回编号)
      • 获取待办列表
      • 获取待办列表总数
    • Ad
      • 读取广告列表
      • 读取广告条数
    • BulkSend
      • 保存RPA群发
      • 删除RPA群发
    • 注册回调地址
      POST
    • 订阅事件
      POST
    • 获取商户TOKEN
      POST
  1. ChatMess

发送消息

POST
/v2/ChatMess/doSendPublicMes
ChatMess

个微发送消息 请求示例#

文本 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "text",
    "Text": "文本内容"
}

图片 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "image",
    "Url": "图片链接",
    "Format":"图片文件后缀"
}

视频 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "video",
    "Url": "视频链接,需带上视频文件的MineType后缀才能成功发送",
    "Format":"图片文件后缀",
    "Description": "描述",
    "ThumbnailUrl": "视频缩略图",
    "Title": "视频标题"
}

文件 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "file",
    "Url": "文件下载链接",
    "Title": "原始文件名称(带后缀 + URL编码)",
    "Format":"文件后缀"
}

链接 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "link",
    "Url": "链接URL",
    "Description": "链接描述",
    "ThumbMediaUrl": "链接缩略图",
    "Title": "链接标题"
}

个微名片 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "card",
    "Text": "粉丝昵称"
}

企微名片 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "qvcard",
    "Text": "粉丝昵称",
    "CompanyName": "所在公司"
}

小程序 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "mp",
    "Text": "小程序名称"
}

公众号 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "gzh",
    "Text": "公众号名称"
}

收款 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "rebpacket"
}

退款 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
    "MsgType": "returnmoney"
}

转发请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "ShareUnionIDNode": "从哪个用户转发",
    "RelationType": 0,
    "MsgType": "forward",
    "Flags": [
        { "Flag":"flag:0000026", "MsgType":"image", "MsgTime": 1647865582, "MsgIndex":1 },
        { "Flag":"flag:0000020", "MsgType":"video", "MsgTime": 1647865582, "MsgIndex":3 },
        { "Flag":"flag:0000023", "MsgType":"link", "MsgTime": 1647865582, "MsgIndex":5 },
        { "Flag":"flag:0000018", "MsgType":"file", "MsgTime": 1647865582, "MsgIndex":10 },
        { "Flag":"flag:0000025", "MsgType":"mp", "MsgTime": 1647865582, "MsgIndex":22 },
        { "Flag":"flag:0000006", "MsgType":"vo", "MsgTime": 1647865582, "MsgIndex":23 },
        { "Flag":"flag:0000006", "MsgType":"vl", "MsgTime": 1647865582, "MsgIndex":23 },
        { "Flag":"flag:0000007", "MsgType":"location", "MsgTime": 1647865582, "MsgIndex",24 }
    ]
}

批量发送 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 0,
  	"MsgType": "batch",
  	"messList": [
		{
			"MsgType": "text",
			"Text": "文本内容"
		},
		{
			"MsgType": "image",
			"ImageUrl": "图片链接,需带上图片文件的MineType后缀才能成功发送",
			"Format": "图片文件后缀"
		},
		{
			"MsgType": "video",
			"Url": "视频链接,需带上视频文件的MineType后缀才能成功发送",
			"Format": "图片文件后缀",
			"Description": "描述",
			"ThumbnailUrl": "视频缩略图",
			"Title": "视频标题","MsgId": "1604549523123"
		},
		{
			"MsgType": "file",
			"Url": "文件下载链接",
			"Title": "原始文件名称(带后缀 + URL编码)",
			"Format": "文件后缀"
		},
		{
			"MsgType": "link",
			"Url": "链接URL",
			"Description": "链接描述",
			"ThumbMediaUrl": "链接缩略图",
			"Title": "链接标题"
		}
  	]
}

企微发送消息 请求示例#

文本 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
    "MsgType": "text",
    "Text": "文本内容"
}

图片 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
    "MsgType": "image",
    "Url": "图片链接",
    "Format":"图片文件后缀"
}

视频 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
    "MsgType": "video",
    "Url": "视频链接,需带上视频文件的MineType后缀才能成功发送",
    "Format":"图片文件后缀",
    "Description": "描述",
    "ThumbnailUrl": "视频缩略图",
    "Title": "视频标题"
}

文件 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
    "MsgType": "file",
    "Url": "文件下载链接",
    "Title": "原始文件名称(带后缀 + URL编码)",
    "Format":"文件后缀"
}

链接 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
    "MsgType": "link",
    "Url": "链接URL",
    "Description": "链接描述",
    "ThumbMediaUrl": "链接缩略图",
    "Title": "链接标题"
}

转发请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "ShareUnionIDNode": "从哪个用户转发",
    "RelationType": 3,
    "MsgType": "forward",
    "Flags": [
        { "Flag":"flag:0000026", "MsgType":"image", "MsgTime": 1647865582, "MsgIndex":1 },
        { "Flag":"flag:0000020", "MsgType":"video", "MsgTime": 1647865582, "MsgIndex":3 },
        { "Flag":"flag:0000023", "MsgType":"link", "MsgTime": 1647865582, "MsgIndex":5 },
        { "Flag":"flag:0000018", "MsgType":"file", "MsgTime": 1647865582, "MsgIndex":10 },
        { "Flag":"flag:0000025", "MsgType":"mp", "MsgTime": 1647865582, "MsgIndex":22 },
        { "Flag":"flag:0000006", "MsgType":"vo", "MsgTime": 1647865582, "MsgIndex":23 },
        { "Flag":"flag:0000006", "MsgType":"vl", "MsgTime": 1647865582, "MsgIndex":23 }
    ]
}

批量发送 请求示例#

{
    "WechatId": "运营机ID",
    "ToUserName": "发给哪个用户",
    "RelationType": 3,
  	"MsgType": "batch",
  	"messList": [
		{
			"MsgType": "text",
			"Text": "文本内容"
		},
		{
			"MsgType": "image",
			"ImageUrl": "图片链接,需带上图片文件的MineType后缀才能成功发送",
			"Format": "图片文件后缀"
		},
		{
			"MsgType": "video",
			"Url": "视频链接,需带上视频文件的MineType后缀才能成功发送",
			"Format": "图片文件后缀",
			"Description": "描述",
			"ThumbnailUrl": "视频缩略图",
			"Title": "视频标题","MsgId": "1604549523123"
		},
		{
			"MsgType": "file",
			"Url": "文件下载链接",
			"Title": "原始文件名称(带后缀 + URL编码)",
			"Format": "文件后缀"
		},
		{
			"MsgType": "link",
			"Url": "链接URL",
			"Description": "链接描述",
			"ThumbMediaUrl": "链接缩略图",
			"Title": "链接标题"
		}
  	]
}

请求参数

Header 参数
Authorization
可选
授权TOKEN,Bearer
TenantId
可选
租户ID,仅限代理商使用
Body 参数application/json
object  | null 
可选
TakeOverKey
string 
接管标识
可选
可选,接管标识可代替ToUserName、WechatId
ToUserName
string 
好友标识
可选
可选,接管标识可代替ToUserName、WechatId
WechatId
string 
运营号ID
可选
可选,接管标识可代替ToUserName、WechatId
MsgType
string 
消息类型
必需
支持:text、image、video、file、link、forward、batch
RelationType
integer 
关系类型
必需
支持:0=个微、1=公众号、2=小程序、3=企业微信
Text
string 
文本消息
可选
示例
{
  "TakeOverKey": "string",
  "ToUserName": "string",
  "WechatId": "string",
  "MsgType": "string",
  "RelationType": 0,
  "Text": "string"
}

示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/v2/ChatMess/doSendPublicMes' \
--header 'Authorization;' \
--header 'TenantId;' \
--header 'Content-Type: application/json' \
--data-raw '{
    "TakeOverKey": "string",
    "ToUserName": "string",
    "WechatId": "string",
    "MsgType": "string",
    "RelationType": 0,
    "Text": "string"
}'

返回响应

🟢200Success
application/json
Body
requestId
string 
必需
errmsg
integer 
必需
succeed
boolean 
必需
msgTime
string 
必需
values
object 
必需
taskId
string 
任务ID
必需
errdesc
string 
必需
示例
{
  "requestId": "string",
  "errmsg": 0,
  "succeed": true,
  "msgTime": "string",
  "values": {
    "taskId": "string"
  },
  "errdesc": "string"
}
上一页
事件发布格式说明
下一页
申请接管
Built with