http://api.polyv.net/live/v2/chat/{channelId}/getHistoryByPage
1、作用:查询一段时间内的聊天记录,时间格式为yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss。
如未提交具体时间,只提交了日期,开始时间默认为日期当天的 00:00:00,结束时间为日期当天的23:59:59
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID
{
"code": 200,
"data": {
"list": [
{
"clientIP": "",
"content": "ss",
"event": "0",
"id": "29451af0-e936-11e7-b267-81b6b5e6b627",
"image": "",
"msyType": "0",
"roomId": "110867",
"time": 1514180448799,
"user": {
"banned": false,
"clientIp": "39.155.185.29",
"nick": "游客",
"pic": "http://www.polyv.net/images/effect/effect-device.png",
"roomId": "110867",
"uid": "P-X2nETUdWGEGmEJEqL8",
"userId": "4b6c3fba-5774-4807-a34e-bb9bc306236e",
"userType": "slice"
},
"userType": "\"slice\""
},
{
"clientIP": "",
"content": "哈哈",
"event": "0",
"id": "f812f360-e94b-11e7-b267-81b6b5e6b627",
"image": "",
"msyType": "0",
"roomId": "110867",
"time": 1514189815190,
"user": {
"banned": false,
"clientIp": "",
"nick": "游客",
"pic": "http://www.polyv.net/images/effect/effect-device.png",
"roomId": "110867",
"uid": "hzx-KN4fAjBnEeumEsY1",
"userId": "1514189810254",
"userType": ""
},
"userType": ""
}
],
"page": 1,
"size": 2,
"totalCount": 6126,
"totalPage": 3063
},
"message": "",
"status": "success"
}
{
"code": 400,
"status": "error",
"message": "appId not found.",
"data": ""
}
{
"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": ""
}
{
"code": 400,
"status": "error",
"message": "the startDay is no right.",
"data": ""
}
{
"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": ""
}
<?php
//引用config.php
include 'config.php';
//接口需要的参数(非sign)赋值
$channelId = "127075";
$startDay = "2017-08-24";
$endDay = "2018-08-24";
$params = array(
'appId'=>$appId,
'startDay'=>$startDay,
'endDay'=>$endDay,
'timestamp'=>$timestamp
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v2/chat/{channelId}/getHistoryByPage?appId=$appId×tamp=$timestamp&sign=$sign&startDay=$startDay&endDay=$endDay";
//输出接口请求结果
echo file_get_contents($url);
?>