Query Lesson Real-Time Status and Online Count
Updated: 2024-10-21 09:33:43
API Description
1、查询课节实时状态和在线人数
2、接口支持https协议
API URL
https://api.polyv.net/hi-class-api/open/lesson/v1/getLessonLiveInfo
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 details on obtaining credentials |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value See signature generation rules |
| lessonIds | true | String | Lesson IDs, comma-separated (max 100 lessons) e.g., 1015,1016 |
Example
http://api.polyv.net/hi-class-api/open/lesson/v1/getLessonLiveInfo?appId=fyirmfdak4×tamp=1638782295111&sign=4FFEE70C353D7F97F9D9057A8A72E453&lessonIds=1015,1016
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See global error description |
| status | String | Response status text |
| error | Error | Error object See global error description |
| data | Array | Empty on failure, response data on success See data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| lessonId | Long | Lesson ID |
| timestamp | Long | Current time, 13-digit timestamp |
| teacherOnlineCount | Long | Number of teachers in the lesson |
| studentOnlineCount | Long | Number of students in the lesson |
| status | Integer | Lesson status 0: Not started 1: In progress 2: Ended 11: Teaching disabled |
Java Request Example
For quick integration of base code, please download the relevant dependency source code. Click here 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.
/**
* 查询课节实时状态和在线人数
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void getLessonLiveInfo() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "https://api.polyv.net/hi-class-api/open/lesson/v1/getLessonLiveInfo";
String lessonIds = "1015,1016";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("lessonIds",lessonIds);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("查询课节实时状态和在线人数:{}",response);
//do somethings
}
Response Example
For system global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"data": [{
"lessonId": 1015,
"timestamp": 1638782349207,
"teacherOnlineCount": 1,
"studentOnlineCount": 9,
"status": 1
}, {
"lessonId": 1016,
"timestamp": 1638782349207,
"teacherOnlineCount": 0,
"studentOnlineCount": 0,
"status": 11
}],
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"error": {
"code": 20046,
"desc": "参数输入超限"
},
"data": null,
"success": false
}
