查询历史聊天信息
接口URL
http://api.polyv.net/live/v2/chat/{channelId}/getHistory
接口说明
1、作用:查询一段时间内的聊天记录,时间格式为yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss。
如未提交具体时间,只提交了日期,开始时间默认为日期当天的 00:00:00,结束时间为日期当天的23:59:59
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID
支持格式
JSON
请求方式
GET,POST
请求数限制
TRUE
请求参数
startDay
是
String
聊天记录的开始时间,格式要求为yyyy-MM-dd(如:2017-08-01)或者 yyyy-MM-dd HH:mm:ss (如:2017-08-01 16:30:12)
endDay
是
string
聊天记录的结束时间,要求同上
appId
是
string
从API设置中获取,在直播系统登记的appId
page
否
int
获取第几页聊天记录,默认为1
limit
否
int
每页记录数,默认为1000
timestamp
是
string
当前13位毫秒级时间戳,3分钟内有效
sign
是
string
签名,32位大写MD5值
userType
否
string
用户类型,可以选择多个类型,用英文逗号隔开。可选值包括: slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
status
否
string
聊天记录状态,默认:pass(已审核),审核状态,pass:已审核,censor:审核中和删除
source
否
string
类型,不填默认公聊,extend:管理员私聊
roomId
否
string
如果有房间号,需要传入房间号,默认不传
响应成功JSON示例
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"accountId": "ee7fe7fbda",
"clientIP": "",
"content": "123",
"event": "",
"id": "9b7b0d20-12b7-11eb-8860-43fdec7e6710",
"image": "",
"msgType": "",
"quote": "",
"roomId": "157468202",
"sessionId": "",
"time": 1603186536120,
"user": {
"actor": "管理员",
"banned": false,
"channelId": "1574682",
"clientIp": "",
"nick": "管理员",
"pic": "//s1.videocc.net/face.png",
"roomId": "157468201",
"sessionId": "fnnjgog6vi",
"uid": "46a6KWLWMdxQwBShAAAC",
"userId": "ee7fe7fbda",
"userType": "manager"
},
"userType": "manager",
"status": "pass",
"sourceType": "public"
},
{
"accountId": "ee7fe7fbda",
"clientIP": "",
"content": "3231",
"event": "",
"id": "9ee931d0-12b7-11eb-b668-b35576b339fa",
"image": "",
"msgType": "",
"quote": "",
"roomId": "157468202",
"sessionId": "",
"time": 1603186541876,
"user": {
"actor": "管理员",
"banned": false,
"channelId": "1574682",
"clientIp": "",
"nick": "管理员",
"pic": "//s1.videocc.net/face.png",
"roomId": "157468202",
"sessionId": "fnnjgog6vi",
"uid": "VQUMlI2l7wcHjiJaAAAC",
"userId": "ee7fe7fbda",
"userType": "manager"
},
"userType": "manager",
"status": "pass",
"sourceType": "public"
}
]
}
响应失败JSON示例:
未输入appId
{
"code": 400,
"status": "error",
"message": "appId not found.",
"data": ""
}
appId不正确
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
时间戳错误
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
签名错误
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
频道号错误
{
"code": 400,
"status": "error",
"message": "channel not found.",
"data": ""
}
开始时间为空
{
"code": 400,
"status": "error",
"message": "startDay can not be empty.",
"data": ""
}
结束时间为空
{
"code": 400,
"status": "error",
"message": "endDay can not be empty.",
"data": ""
}
开始时间格式不正确 (正确格式为yyyy-MM-dd)
{
"code": 400,
"status": "error",
"message": "the startDay is no right.",
"data": ""
}
开始时间格式不正确 (正确格式为yyyy-MM-dd)
{
"code": 400,
"status": "error",
"message": "the endDay is no right.",
"data": ""
}
结束时间晚于开始时间
{
"code": 400,
"status": "error",
"message": "the endDay can not be earlier than the startDay.",
"data": ""
}
其他错误
{
"code": 400,
"status": "error",
"message": "无法访问聊天室数据",
"data": ""
}
字段说明
code
int
请求状态响应码
status
string
请求状态
message
string
错误信息
data
array
数据列表
data[0].accountId
string
账号Id
data[0].clientIP
string
用户IP
data[0].content
string
聊天内容
data[0].id
string
聊天消息id
data[0].image
string
图片消息的图片地址
data[0].msgType
string
目前取值: redpaper: 红包消息; chatImg:图片消息; custom:自定义消息(通过socket发送的自定义消息); reward:打赏消息; customerMessage:自定义消息(通过http接口发送的自定义消息) 为空(msgType="")时表示普通聊天消息;
data[0].quote
string
data[0].roomId
string
频道号
data[0].sessionId
string
场次号
data[0].time
string
发送消息时的时间戳
data[0].status
string
审核状态,pass:已审核,censor:审核中,delete:删除
data[0].userType
string
用户类型,可能的值为:slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
data[0].sourceType
string
消息来源,目前有public(群聊)、extend(管理员私聊)
data[0].user.clientIp
string
用户IP
data[0].user.nick
string
观众昵称
data[0].user.pic
string
观众头像
data[0].user.roomId
string
房间号
data[0].user.userId
string
用户唯一标示
data[0].user.uid
string
socketId
data[0].user.sessionId
string
场次号
data[0].user.channelId
int
频道号
data[0].user.banned
boolean
是否禁言
data[0].user.actor
string
角色
data[0].user.userType
string
用户类型,可能的值为:slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
content类型说明
content
字段类型受msgType
字段影响,如果msgType
为空,则表示普通发言,content
为字符串类型。如果msgType
为其它类型,则content
为对象。
msyType为redpaper
表示红包,content
对象为
conetnt
string
红包说明
msgSource
string
字符串redpaper
number
number
红包数量
redCacheId
string
红包缓存id
redpackId
string
红包id
totalAmount
number
红包总数量
type
string
红包类型,normal为普通红包,rain为红包雨
msyType为chatImg
发送图片,content
对象为
id
string
图片id
msgSource
string
字符串 chatImg
size
object
图片尺寸信息,其中width表示宽度,height表示高度
status
string
图片成功状态
type
string
字符串chatImg
uploadImgUrl
string
图片链接地址
msyType为custom
发送自定义消息,content
对象为
msgSource
string
字符串custom
EVENT
string
自定义消息事件名称
version
number
自定义消息版本
emitMode
number
自定义消息广播类型,0表示广播到房间内所有人,包括自己;1表示广播到房间,除了自己;2表示指定socketID进行广播。
tip
string
自定义消息提示
data
object
自定义消息内容,由调用者自定义
php请求示例
$appId,
'startDay'=>$startDay,
'endDay'=>$endDay,
'timestamp'=>$timestamp
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.live.polyv.net/v2/chat/$channelId/getHistory?appId=$appId×tamp=$timestamp&sign=$sign&startDay=$startDay&endDay=$endDay";
//输出接口请求结果
echo file_get_contents($url);
?>
Last updated
Was this helpful?