Query Channel Q&A Records
Updated: 2022-09-02 18:08:07
API Description
1、通过频道号,查询咨询提问记录
2、接口支持https协议
3、接口URL中的{channelId}为"频道号"
API URL
http://api.polyv.net/live/v2/chat/{channelId}/getQuestion
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
| begin | false | Integer | Starting index, starting from 0 |
| end | false | Integer | Ending index, -1 means no pagination |
Example
http://api.polyv.net/live/v2/chat/2191569/getQuestion?appId=frlr1zazn3&sign=40763580D3C4C34CF268018E154944D3&end=1&begin=0×tamp=1616636714152
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See Global Error Codes |
| status | String | Response status text |
| message | String | Response description, provides error details when code is 400 or 500 |
| data | Array | List of Q&A records See data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| id | String | Message ID |
| content | String | Content |
| time | Long | Time, 13-digit timestamp |
| s_userId | String | Questioner ID |
| event | String | Message type T_ANSWER: Instructor answer S_QUESTION: Student question |
| sourceType | String | Audience source |
| user | Object | Speaker information See user field description |
user Field Description
| Parameter | Type | Description |
|---|---|---|
| nick | String | Speaker nickname |
| pic | String | Speaker avatar |
| userId | String | Speaker ID |
| sessionId | String | Session number |
| userType | String | Speaker type value |
| banned | Boolean | Whether muted (true/false) |
| channelId | String | Channel ID |
Java Request Example
For quick integration, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(InteractionQuestionTest.class);
/**
* 查询频道提问记录
* @throws IOException
*/
@Test
public void testGetQuestionList() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "2191569";
String url = "http://api.polyv.net/live/v2/chat/"+channelId+"/getQuestion";
Integer begin = 0;
Integer end = 1;
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("begin",begin.toString());
requestMap.put("end",end.toString());
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询频道提问记录接口返回值:{}",response);
}
Response Example
For global error codes, see Global Error Codes
Success Example
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"id": "ef523640-855c-11eb-ac86-91e249016089",
"user": {
"nick": "卉",
"pic": "https://thirdwx.qlogo.cn/mmopen/vi_32/3lMXVJoLMLJibnkFuA23lyqj5MOQufhW5ATvHuB8byssutficHKU0u7OMx5OQgg9WNVuHf44AXfbAMMAZejuYFTg/132",
"userId": "ovtl9t_RxnrTdqkXqkT5Q5lnxp2A",
"sessionId": null,
"userType": "student",
"banned": false,
"channelId": null
},
"content": "很长的提问",
"time": 1615791976356,
"s_userId": null,
"event": "S_QUESTION",
"sourceType": null
},
{
"id": "e9090520-855c-11eb-ac86-91e249016089",
"user": {
"nick": "卉",
"pic": "https://thirdwx.qlogo.cn/mmopen/vi_32/3lMXVJoLMLJibnkFuA23lyqj5MOQufhW5ATvHuB8byssutficHKU0u7OMx5OQgg9WNVuHf44AXfbAMMAZejuYFTg/132",
"userId": "ovtl9t_RxnrTdqkXqkT5Q5lnxp2A",
"sessionId": null,
"userType": "student",
"banned": false,
"channelId": null
},
"content": "提问",
"time": 1615791965810,
"s_userId": null,
"event": "S_QUESTION",
"sourceType": null
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
