发送消息
简要描述
- 模拟身份向指定用户或群组发送消息,也可用于从其他平台导入历史记录。
 
请求方式
post
请求URL
{API_ADDRESS}/msg/send_msg
Header
| header名 | 示例值 | 选填 | 类型 | 说明 | 
|---|---|---|---|---|
| operationID | 1646445464564 | 必填 | string | 用于全局链路追踪,建议使用时间戳,在每个请求中独立 | 
| token | eyJhbxxxx3Xs | 必填 | string | 管理员 token | 
请求参数示例
{
  "sendID": "openIMAdmin",
  "recvID": "2839678182",
  "groupID": "",
  "senderNickname": "openIMAdmin-Gordon",
  "senderFaceURL": "http://www.head.com",
  "senderPlatformID": 1,
  "content": {
    "content": "hello!!"
  },
  "contentType": 101,
  "sessionType": 1,
  "isOnlineOnly": false,
  "notOfflinePush": false,
  "sendTime": 1695212630740,
  "offlinePushInfo": {
    "title": "send message",
    "desc": "",
    "ex": "",
    "iOSPushSound": "default",
    "iOSBadgeCount": true
  },
  "ex": "ex"
}
| 字段名 | 选填 | 类型 | 说明 | 
|---|---|---|---|
| sendID | 必填 | string | 系统通知号ID,或用户ID | 
| recvID | 选填 | string | 接收者ID,sessionType1或者4时必填,如果是群聊则不填 | 
| groupID | 选填 | string | 群ID,sessionType3时必填,如果为单聊则不填 | 
| senderNickname | 选填 | string | 消息发送者昵称 | 
| senderFaceURL | 选填 | string | 消息发送者头像 | 
| senderPlatformID | 选填 | int | 消息发送者的终端类型,模拟用户发送时填写,取值为1-9 | 
| content | 必填 | object | 消息的具体内容,内部是json 对象,其他消息的详细字段请参考消息类型格式描述文档 | 
| content.content | 必填 | string | 消息内容 | 
| contentType | 必填 | int | 消息类型 | 
| sessionType | 必填 | int | 会话类型 | 
| isOnlineOnly | 选填 | boolean | 接收者在线才能收到,否则将会丢失 | 
| notOfflinePush | 选填 | boolean | 不进行离线推送 | 
| sendTime | 选填 | int | 消息发送时间,仅导入消息时填写,单位毫秒 | 
| offlinePushInfo | 选填 | object | 离线推送的具体内容,如果不填写,使用服务器默认推送标题。notOfflinePush为true时该字段不会使用。 | 
| offlinePushInfo.title | 选填 | string | 推送的标题 | 
| offlinePushInfo.desc | 选填 | string | 推送的具体描述 | 
| offlinePushInfo.ex | 选填 | string | 扩展字段 | 
| offlinePushInfo.iOSPushSound | 选填 | string | IOS的推送声音 | 
| offlinePushInfo.iOSBadgeCount | 选填 | boolean | IOS推送消息是否计入桌面图标未读数 | 
| ex | 选填 | string | 扩展字段 | 
成功返回示例
{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {
    "serverMsgID": "8698dd5d163dd79b8fdfa333fee06f40",
    "clientMsgID": "1ca0e4cf279ad5cce6b28331b2b42092",
    "sendTime": 1679558586210
  }
}
成功返回示例的参数说明
| 参数名 | 类型 | 说明 | 
|---|---|---|
| errCode | int | 错误码,0表示成功 | 
| errMsg | string | 错误简要信息,为空 | 
| errDlt | errDlt | 错误详细信息,为空 | 
| data | object | 通用数据对象,具体结构见下方 | 
| serverMsgID | string | 服务器消息ID,预留字段 | 
| clientMsgID | string | 客户端消息ID,此ID为消息唯一ID | 
| sendTime | int | 消息发送的时间 | 
失败返回示例
{
  "errCode": 1004,
  "errMsg": "RecordNotFoundError",
  "errDlt": ": [1004]RecordNotFoundError"
}
失败返回示例的参数说明
| 参数名 | 类型 | 说明 | 
|---|---|---|
| errCode | int | 错误码,具体查看全局错误码文档 | 
| errMsg | string | 错误简要信息 | 
| errDlt | errDlt | 错误详细信息 |