分頁取得聊天室資訊
更新時間:2022-05-23 14:30:29
介面URL
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
支援格式
JSON
請求方式
POST,GET
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| 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 | 使用者類型,可以選擇多個類型,用英文逗號隔開 |
回應成功JSON範例
{
"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"
}
回應失敗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 | 請求狀態回應碼 |
| status | 請求狀態 |
| message | 錯誤訊息 |
| clientIP | 使用者IP |
| content | 聊天內容 |
| id | 聊天訊息id |
| image | 圖片訊息的圖片位址 |
| roomId | 頻道號 |
| time | 發送訊息時的時間戳記 |
| clientIp | 使用者IP |
| nick | 觀眾暱稱 |
| pic | 觀眾頭像 |
| roomId | 頻道號 |
| uid | socket分配的id,其中 uid=1 表示打賞、uid=2 表示自訂訊息、uid=3 表示紅包 |
| userId | 使用者唯一標示 |
| userType | 使用者類型,目前有teacher(老師)、assistant(助教)、manager(管理員)、slice(雲課堂學員) |
| page | 當前頁 |
| size | 每頁資料大小 |
| totalCount | 總資料大小 |
| totalPage | 總頁數 |
php請求範例
<?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);
?>
