查詢歷史聊天資訊
更新時間:2022-05-23 19:02:59
介面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 | 自訂訊息內容,由呼叫者自訂 |
