1、开启了“讲义库”功能后(如需开通请联系售后),通过此接口将讲师和公共讲义库中的文档关联起来,从而实现在不需要重复上传的情况下,多个讲师共用同一份文档
2、包括新增、解除讲师文档关系
3、接口支持https协议
https://api.polyv.net/live/v4/channel/doc/teacher/update-relation
https://api.polyv.net/live/v4/channel/doc/teacher/update-relation&appId=frlr1zazn3&operation=1&sign=FC2296E942D2DB118C64C11AD941445D&teacherId=p001×tamp=1661754430000
fileIds=xxxxxxxxe674c952815ad1a09c66e10xxxxxxxxcommon
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
/**
* 更新讲师文档关系
*/
@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);
}
{
"code":200,
"status":"success",
"message":"",
"data":null
}
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}