保利威文档中心

帮助中心

创建课节

更新时间:2024-10-21 09:33:43

接口描述

1、创建课节
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

接口URL

http://api.polyv.net/hi-class-api/open/lesson/v1/add

请求方式

POST

接口约束

1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看

请求参数描述

参数名 必选 类型 说明
appId true String 账号appId【详见获取密钥
timestamp true Long 当前13位毫秒级时间戳,3分钟内有效
sign true String 签名,为32位大写的MD5值【详见签名生成规则

请求体参数描述

参数名 必选 类型 说明
name true String 课节名称,长度1~128
startTime true Long 开始时间,格式为: 13位时间戳
duration true Integer 上课时长,单位: 分钟,5~180
linkNumber true Integer 连麦人数,0~16
autoConnectMicroEnabled false String 是否自动连麦,默认:N
Y:自动连麦
N:手动上麦
autoRecordCourseEnabled false String 是否自动录制课程,默认:N
Y:自动录制
N:手动录制
watchCondition true String 观看条件
NULL:无条件
CODE:验证码
WHITE_LIST:白名单
DIRECT:独立授权
code false String 当观看条件为CODE时需要填写观看验证码(限制16位以内)
secretKey false String 观看条件为独立授权时传,不传则后台自动生成(限制32位以内)
resolution false Integer 录制清晰度, 720, 1080
playResolution false Integer 上课清晰度, 360(如果需要设置更高的清晰度,请联系相关工作人员)
cover false String 封面地址URL,长度1~255
teacherId false String 老师id,如不传,则根据teacherMobile查找现有老师,如果查找不到,则创建一个老师
teacherCode false String 老师登录手机区号,默认 +86
teacherMobile false String 老师手机号,长度5~15
teacherName false String 老师名称,如传入的信息可以查找到现有老师,会更新老师名称
teacherPasswd false String 老师密码,长度6~8

示例

http://api.polyv.net/hi-class-api/open/lesson/v1/add?appId=frlr1zazn3&sign=A80D0E7115D0D1BF5648AE2AB123C0FD&timestamp=1621839827266

请求体参数

{
    "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"
}

响应参数描述

参数名 类型 说明
code Integer 响应状态码,200为成功返回,非200为失败【详见全局错误说明
status String 响应状态文本信息
error Error 错误对象【详见全局错误说明
data Object 请求失败时为空,请求成功时为课节信息 【详见data字段描述

data字段描述

参数名 类型 说明
lessonId Long 课节ID
name String 课节名称
teacherId String 老师ID
teacherCode String 老师登录手机区号
teacherMobile String 老师账号
teacherPasswd String 老师账号密码
startTime Long 开始时间,格式为: 13位时间戳
endTime Long 开始时间,格式为: 13位时间戳
duration Integer 上课时长,单位: 分钟
linkNumber Integer 连麦人数 0 - 16
autoConnectMicroEnabled String 是否自动连麦
Y:自动连麦
N:不自动连麦
autoRecordCourseEnabled String 是否自动录制
Y:自动录制
N:不自动录制
watchCondition String 观看条件
NULL:无条件
CODE:验证码
WHITE_LIST:白名单
DIRECT:独立授权
code String 观看密码,当观看条件为CODE时需要填写密码
secretKey String 授权观看KEY
cover String 封面URL
resolution Integer 录制清晰度, 720, 1080
playResolution Integer 上课清晰度, 360

Java请求示例

快速接入基础代码请下载相关依赖源码点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。

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);
}

响应示例

系统全局错误说明详见全局错误说明

成功示例

{
    "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
}

异常示例

{
    "code": 500,
    "status": "error",
    "error": {
        "code": 10005,
        "desc": "系统异常"
    },
    "data": null,
    "success": false
}
联系客服,在线咨询