Polyv Help Center

Help Center

Instructor Document Relationship Management

Updated: 2022-11-14 16:59:37

API Description

1、开启了“讲义库”功能后(如需开通请联系售后),通过此接口将讲师和公共讲义库中的文档关联起来,从而实现在不需要重复上传的情况下,多个讲师共用同一份文档
2、包括新增、解除讲师文档关系
3、接口支持https协议

API URL

https://api.polyv.net/live/v4/channel/doc/teacher/update-relation

Online API Call

Request Method

POST

API Constraints

  1. API calls have frequency limits. Click for 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 within 3 minutes
sign true String Signature, a 32-character uppercase MD5 value [See Signature Generation Rules]
operation true Integer Operation,
1: Add binding relationship. If the binding relationship already exists, it will not be added again, only the association time will be updated. The list query will be sorted in descending order by this association time by default.
2: Unbind relationship
teacherId true String Instructor ID, up to 32 ASCII visible characters, which is the customTeacherId passed in the Create Channel API or Update Channel API
fileIds true String Document IDs, multiple document IDs separated by commas, up to 100 at a time

Example

https://api.polyv.net/live/v4/channel/doc/teacher/update-relation&appId=frlr1zazn3&operation=1&sign=FC2296E942D2DB118C64C11AD941445D&teacherId=p001&timestamp=1661754430000

Form parameters, not participating in signature, Content-Type: application/x-www-form-urlencoded

fileIds=xxxxxxxxe674c952815ad1a09c66e10xxxxxxxxcommon

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
message String Response description, when code is 400 or 500, provides auxiliary error reason description
data Object None currently
Data Parameter Description

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 code project. HttpUtil.java and LiveSignUtil.java in the test cases are included in the downloaded file.

It is strongly recommended that you use the Live Java SDK to complete API functionality integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

/**
 * 更新讲师文档关系
 */
@Test
public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
    // 公共参数,填写自己的实际参数,需放置于QueryString
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    // 业务参数
    Integer operation = 1;
    String teacherId = "tid";
    String fileIds = "xxxxxxxxxxxxxjg112hhs71zzza888axxxxxxxxcommon,xxxxxxxxxxxx123451a30dd21919999xxxxxxxxcommon";
        
    String url = "https://api.polyv.net/live/v4/channel/doc/teacher/update-relation";
    // QueryString中参数需要参与生成签名
    Map<String,String> queryStringMap = new HashMap<>();
    // 公共参数
    queryStringMap.put("appId", appId);
    queryStringMap.put("timestamp", timestamp);
    // 业务参数
    queryStringMap.put("operation", String.valueOf(operation));
    queryStringMap.put("teacherId", teacherId);
    // 生成签名
    String sign = LiveSignUtil.getSign(requestMap, appSecret);
    queryStringMap.put("sign", sign);
    
    // 将参数放置于QueryString
    url = HttpUtil.appendUrl(url, requestMap);
    System.out.println(url);
    
    // 请求体参数,不参与签名
    Map<String,String> formBodyMap = new HashMap<>();
    formBodyMap.put("fileIds", fileIds);
    // 发起 post application/x-www-form-urlencoded 请求获取到响应数据 response
    String response = HttpUtil.postFormBody(url, formBodyMap);
    System.out.println(response);
}

Response Example

For system global error descriptions, see Global Error Description

Success Example

{
    "code":200,
    "status":"success",
    "message":"",
    "data":null
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询