保利威文档中心

幫助中心

建立課節

更新時間: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
}
联系客服,在线咨询