> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/vclass-copy/api/lesson/get_lesson.md).

# 获取课节信息

### 接口描述

```
1、获取课节信息
2、接口支持https协议
```

### 接口URL

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

### 请求方式

```
POST
```

### 接口约束

1、接口同时支持HTTP 、HTTPS ，建议使用HTTPS 确保接口安全，接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/limit/README.md)

### 请求参数描述

| 参数名       | 必选   | 类型     | 说明                                                                                                                         |
| --------- | ---- | ------ | -------------------------------------------------------------------------------------------------------------------------- |
| appId     | true | String | 账号appId【详见[获取密钥](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/getSecretKey/README.md)】       |
| timestamp | true | Long   | 当前13位毫秒级时间戳，3分钟内有效                                                                                                         |
| sign      | true | String | 签名，为32位大写的MD5值【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/buildSign/README.md)】 |

### 请求体参数描述

| 参数名      | 必选   | 类型   | 说明  |
| -------- | ---- | ---- | --- |
| lessonId | true | Long | 课节号 |

### 示例

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

请求体参数

```body
{
	"lessonId": 1
}
```

### 响应参数描述

| 参数名    | 类型      | 说明                                                                                                                                             |
| ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| code   | Integer | 响应状态码，200为成功返回，非200为失败【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/errorInfo/README.md)】             |
| status | String  | 响应状态文本信息                                                                                                                                       |
| error  | Error   | 错误对象【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/errorInfo/README.md)】                               |
| data   | Object  | 请求失败时为空，请求成功时为课节信息 【详见[data字段描述](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/lesson/add_lesson.md?id=data字段描述)】 |

#### data字段描述

| 参数名                     | 类型      | 说明                                                                    |
| ----------------------- | ------- | --------------------------------------------------------------------- |
| lessonId                | Long    | 课节ID                                                                  |
| name                    | String  | 课节名称                                                                  |
| teacherId               | String  | 老师ID                                                                  |
| teacherCode             | String  | 老师登录手机区号                                                              |
| teacherMobile           | String  | 老师账号                                                                  |
| teacherPasswd           | String  | 老师账号密码                                                                |
| startTime               | Long    | 开始时间，格式为: 13位时间戳                                                      |
| endTime                 | Long    | 结束时间，格式为: 13位时间戳                                                      |
| duration                | Integer | 上课时长，单位: 分钟                                                           |
| status                  | Integer | <p>课节状态<br>0：未开始<br>1：上课中<br>2：已下课<br>11：禁止上课</p>                     |
| linkNumber              | Integer | 连麦人数 0 - 16                                                           |
| autoConnectMicroEnabled | String  | <p>是否自动连麦<br>Y：自动连麦<br>N：手动上麦</p>                                     |
| autoRecordCourseEnabled | String  | <p>是否自动录制课程<br>Y：自动录制<br>N：手动录制</p>                                   |
| watchCondition          | String  | <p>观看条件<br>NULL：无条件<br>CODE：验证码<br>WHITE\_LIST：白名单<br>DIRECT：独立授权</p> |
| code                    | String  | 观看密码，当观看条件为CODE时需要填写密码                                                |
| secretKey               | String  | 授权观看KEY                                                               |
| cover                   | String  | 封面URL                                                                 |
| resolution              | Integer | 录制清晰度, 720, 1080                                                      |
| playResolution          | Integer | 上课清晰度, 360                                                            |

### Java请求示例

快速接入基础代码请下载相关依赖源码， [点击下载源代码](https://git.polyv.net/help-center/document-center/-/blob/master/third_res/util.zip) ,下载后加入到自己的源码工程中即可。测试用例中的**HttpUtil.java 和 LiveSignUtil.java** 都包含在下载文件中。

```java
    /**
     * 获取课节信息
     * @throws IOException
     * @throws NoSuchAlgorithmException
     */
    @Test
    public void getLesson() 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/get";
        String lessonId = "8970";
        
        //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("lessonId", lessonId);
        
        url = HttpUtil.appendUrl(url, requestMap);
        String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
        log.info("测试获取课节信息成功：{}", response);
        //do somethings
    }
```

### 响应示例

系统全局错误说明详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vclass/api/errorInfo/README.md)

成功示例

```json
{
	"code": 200,
	"status": "success",
	"data": {
		"lessonId": 3,
		"lessonCode": "bmv87857",
		"name": "课节ABC",
		"status": 0,
		"startTime": "2021-06-16 18:23",
		"endTime": "2021-06-16 19:03",
		"duration": 40,
		"cover": "//s1.videocc.net/default-img/small-class/default-cover.png",
		"teacherId": "fzkl43t2k1",
		"teacherName": "张老师",
		"webStartUrl": "https://s.vclass.com/live-web-hi-class/teacher/login?lessonId=3",
		"watchStartUrl": "https://s.vclass.com/live-web-hi-class/student/login?lessonId=3",
		"aloneWatch": "N",
		"teacherCode": "+86",
		"teacherMobile": "150188750789",
		"teacherPasswd": "123456",
		"linkNumber": 1,
		"autoConnectMicroEnabled": "Y",
		"autoRecordCourseEnabled": "Y"
	},
	"success": true
}
```

异常示例

```json
{
  "code": 400,
  "status": "error",
  "data": "",
  "error": {
    "code": xx,
    "desc": "错误描述"
  }
}
```
