Create Lesson
Updated: 2024-10-21 09:33:43
Interface Description
1、创建课节
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/hi-class-api/open/lesson/v1/add
Request Method
POST
Interface Constraints
- The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details
Request Parameter Description
| 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-digit uppercase MD5 value See Signature Generation Rules |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Lesson name, length 1~128 |
| startTime | true | Long | Start time, format: 13-digit timestamp |
| duration | true | Integer | Class duration, unit: minutes, 5~180 |
| linkNumber | true | Integer | Number of participants for co-streaming, 0~16 |
| autoConnectMicroEnabled | false | String | Auto co-streaming, default: N Y: Auto co-streaming N: Manual co-streaming |
| autoRecordCourseEnabled | false | String | Auto course recording, default: N Y: Auto recording N: Manual recording |
| watchCondition | true | String | Watch condition NULL: No condition CODE: Verification code WHITE_LIST: Whitelist DIRECT: Independent authorization |
| code | false | String | Required when watch condition is CODE, fill in the watch verification code (limited to 16 characters) |
| secretKey | false | String | Pass when watch condition is independent authorization; if not passed, the backend will auto-generate (limited to 32 characters) |
| resolution | false | Integer | Recording resolution, 720, 1080 |
| playResolution | false | Integer | Class resolution, 360 (contact relevant staff if higher resolution is needed) |
| cover | false | String | Cover URL, length 1~255 |
| teacherId | false | String | Teacher ID. If not passed, search for an existing teacher by teacherMobile; if not found, create a teacher |
| teacherCode | false | String | Teacher login phone area code, default +86 |
| teacherMobile | false | String | Teacher phone number, length 5~15 |
| teacherName | false | String | Teacher name. If the provided info matches an existing teacher, the teacher name will be updated |
| teacherPasswd | false | String | Teacher password, length 6~8 |
Example
http://api.polyv.net/hi-class-api/open/lesson/v1/add?appId=frlr1zazn3&sign=A80D0E7115D0D1BF5648AE2AB123C0FD×tamp=1621839827266
Request Body Parameters
{
"duration": "30",
"cover": "https://liveimages.videocc.net/uploaded/images/2021/08/g1xcu49u12.jpg",
"watchCondition": "CODE",
"code": "1234",
"linkNumber": "1",
"name": "测试创建课节",
"teacherMobile": "15555555555",
"startTime": "1634630909795",
"playResolution": "360",
"autoConnectMicroEnabled": "N",
"resolution": "720",
"teacherPasswd": "123456"
}
Response Parameter Description
| 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 | Object | Empty on failure, lesson info on success See data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| lessonId | Long | Lesson ID |
| name | String | Lesson name |
| teacherId | String | Teacher ID |
| teacherCode | String | Teacher login phone area code |
| teacherMobile | String | Teacher account |
| teacherPasswd | String | Teacher account password |
| startTime | Long | Start time, format: 13-digit timestamp |
| endTime | Long | End time, format: 13-digit timestamp |
| duration | Integer | Class duration, unit: minutes |
| linkNumber | Integer | Number of participants for co-streaming, 0 - 16 |
| autoConnectMicroEnabled | String | Auto co-streaming Y: Auto co-streaming N: Not auto co-streaming |
| autoRecordCourseEnabled | String | Auto recording Y: Auto recording N: Not auto recording |
| watchCondition | String | Watch condition NULL: No condition CODE: Verification code WHITE_LIST: Whitelist DIRECT: Independent authorization |
| code | String | Watch password, required when watch condition is CODE |
| secretKey | String | Authorized watch KEY |
| cover | String | Cover URL |
| resolution | Integer | Recording resolution, 720, 1080 |
| playResolution | Integer | Class resolution, 360 |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. HttpUtil.java and LiveSignUtil.java in the test case are included in the download file.
private static final Logger log = LoggerFactory.getLogger(VClassLessonTest.class);
/**
* 创建课节
* @throws IOException
*/
@Test
public void createLesson() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/hi-class-api/open/lesson/v1/add";
String name = "测试创建课节";
String startTime = "1634630909795";
String duration = "30";
String linkNumber = "1";
String autoConnectMicroEnabled = "N";
String watchCondition = "CODE";
String code = "1234";
String resolution = "720";
String playResolution = "360";
String cover = "https://liveimages.videocc.net/uploaded/images/2021/08/g1xcu49u12.jpg";
String teacherMobile = "15555555555";
String teacherPasswd = "123456";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("name", name);
jsonMap.put("startTime", startTime);
jsonMap.put("duration", duration);
jsonMap.put("linkNumber", linkNumber);
jsonMap.put("autoConnectMicroEnabled", autoConnectMicroEnabled);
jsonMap.put("watchCondition", watchCondition);
jsonMap.put("code", code);
jsonMap.put("resolution", resolution);
jsonMap.put("playResolution", playResolution);
jsonMap.put("cover", cover);
jsonMap.put("teacherMobile", teacherMobile);
jsonMap.put("teacherPasswd", teacherPasswd);
url = HttpUtil.appendUrl(url,requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap),null);
log.info("测试创建课节成功:{}", response);
}
Response Example
For system global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "5bc5c3a4a88a487192cb0256b1dadb7f.97.16346276665928621",
"data": {
"lessonId": 8970,
"lessonCode": "zah58475",
"name": "测试创建课节",
"status": 0,
"startTime": 1634630910000,
"endTime": 1634632710000,
"duration": 30,
"watchCondition": "CODE",
"code": "1234",
"secretKey": "hjbc57jyim",
"cover": "https://liveimages.videocc.net/uploaded/images/2021/08/g1xcu49u12.jpg",
"teacherId": "g3fdl05syf",
"teacherName": "郑老师",
"courseCount": 0,
"webStartUrl": "https://s.vclass.com/live-web-hi-class/teacher/login?lessonId=8970",
"watchStartUrl": "https://s.vclass.com/live-web-hi-class/student/login?lessonId=8970",
"aloneWatch": "Y",
"cataId": 0,
"teacherCode": "+86",
"teacherMobile": "15555555555",
"teacherPasswd": "123456",
"linkNumber": 1,
"autoConnectMicroEnabled": "N",
"autoRecordCourseEnabled": "N",
"resolution": 720,
"playResolution": 360
},
"success": true
}
Error Example
{
"code": 500,
"status": "error",
"error": {
"code": 10005,
"desc": "系统异常"
},
"data": null,
"success": false
}
