修改频道音频审核设置
接口描述
1、<p>更新频道音频审核设置</p>
2、(timestamp, appId, channelId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
4、按账号开通版本校验:audioModerationFunctionEnable 为 Y(金融版)或 AI(大模型版)即视为已开通;未开通(N、空或其他值)返回错误码 1041。请求体为合并结构,金融版提交金融版字段、大模型版提交大模型版字段,由服务端按账号版本校验【详见[校验规则](#校验规则)】
接口URL
http://api.polyv.net/live/v4/channel/audio-moderation/update
请求方式
POST
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| appId | true | String | 账号appId【详见获取密钥】 |
| channelId | true | String | 频道ID |
| sign | true | String | 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则】 |
| timestamp | true | String | 当前13位毫秒级时间戳,3分钟内有效 |
请求体参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| badwordEnabled | true | String | 应用严禁词开关,Y/N |
| customRule | false | String | 自定义审核规则(大模型版),最长2000字,llmAuditEnabled=Y 时生效 |
| illegalNotify | false | Object | 违规提醒配置【详见IllegalNotify参数描述】 |
| llmAuditEnabled | false | String | 大模型审核开关,Y/N(大模型版) |
| moderationEnabled | true | String | 审核开关 Y:开启 N:关闭 |
| moderationStrategy | false | String | 审核策略(金融版必填) easy:宽松审核策略 normal:一般审核策略 strict:严格审核策略 |
IllegalNotify参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| assistantEnabled | false | String | 助理提醒 Y:开启 N:关闭 |
| monitorEnabled | false | String | 监播提醒 Y:开启 N:关闭 |
| notifyLevel | false | String | 接收提醒等级(大模型版) all:所有风险项 medium_plus:中风险及以上 high_only:仅高风险项 |
| notifyUrl | false | String | 对外提醒URL(大模型版);为空表示关闭对外提醒,有值时违规事件会推送到该URL |
| platformEnabled | false | String | 平台通知 Y:开启 N:关闭 |
| talentEnabled | false | String | 主播提醒 Y:开启 N:关闭 |
校验规则
1、账号版本由 audioModerationFunctionEnable 判断:Y=金融版、AI=大模型版;未开通(N、空或其他值)返回错误码 1041。 2、金融版:moderationStrategy 必填且合法(easy/normal/strict),未传或非法返回错误码 30130。 3、大模型版:moderationEnabled=Y 时,llmAuditEnabled 与 badwordEnabled 至少一个为 Y,否则返回错误码 30131;moderationStrategy 可不传,服务端落默认值 easy(不参与大模型版审核)。 4、llmAuditEnabled=Y 时,customRule 作为大模型审核规则保存并参与审核;llmAuditEnabled=N 时 customRule 可保留但不参与审核。 5、notifyUrl 为空表示关闭对外提醒;notifyUrl 有值时按 notifyLevel 判断需要推送的风险等级(notifyLevel 换算为 notifyScore 落库:all=0、medium_plus=50、high_only=80)。 6、moderationEnabled=N 时,系统仍保存子开关配置,但音频审核不生效。
示例
http://api.polyv.net/live/v4/channel/audio-moderation/update?appId=gga9dadhzm&sign=4D6E18824022FB69A10142E788E2F184&channelId=3775168×tamp=1678088144335
请求体json参数:
金融版请求示例:
{
"moderationEnabled": "Y",
"moderationStrategy": "normal",
"badwordEnabled": "N",
"illegalNotify": {
"monitorEnabled": "Y",
"talentEnabled": "Y",
"assistantEnabled": "Y",
"platformEnabled": "Y"
}
}
大模型版请求示例:
{
"moderationEnabled": "Y",
"llmAuditEnabled": "Y",
"customRule": "禁止主播引导观众添加微信、QQ等社交账号进行私下交易;禁止主播在直播中提及其他竞品平台名称;禁止主播使用攻击性语言。",
"badwordEnabled": "Y",
"illegalNotify": {
"monitorEnabled": "Y",
"talentEnabled": "N",
"assistantEnabled": "Y",
"platformEnabled": "N",
"notifyUrl": "https://example.com/audio-moderation/callback",
"notifyLevel": "medium_plus"
}
}
响应参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 状态码,与 http 状态码相同,用于确定基本的响应状态 |
| data | Boolean | 成功响应的数据 |
| error | Object | 状态码非200时的错误信息【详见Error参数描述】 |
| requestId | String | 请求ID,每次请求生成的唯一的 UUID,仅可用于排查、调试,不应该和业务挂上钩 |
| status | String | 响应结果,由业务决定,成功返回success,失败返回error |
| success | Boolean | 是否成功响应 |
Error参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 错误代码,用于确定具体的错误原因 |
| desc | String | 错误描述,与 error.code 对应 |
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 更新频道音频审核设置
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void audioModerationUpdateTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/audio-moderation/update";
String channelId = "";
String badwordEnabled = "";
String illegalNotify = "";
String moderationEnabled = "";
String moderationStrategy = "";
String assistantEnabled = "";
String monitorEnabled = "";
String platformEnabled = "";
String talentEnabled = "";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("channelId", channelId);
jsonMap.put("badwordEnabled", badwordEnabled);
jsonMap.put("illegalNotify", illegalNotify);
jsonMap.put("moderationEnabled", moderationEnabled);
jsonMap.put("moderationStrategy", moderationStrategy);
jsonMap.put("assistantEnabled", assistantEnabled);
jsonMap.put("monitorEnabled", monitorEnabled);
jsonMap.put("platformEnabled", platformEnabled);
jsonMap.put("talentEnabled", talentEnabled);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试更新频道音频审核设置成功:{}", response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code": 200,
"status": "success",
"requestId": "414afeb28f1c4f0ca17e1c3c1e39d247.13959.16780881532635057",
"data": true,
"success": true
}
异常示例
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
业务错误码说明
| 错误码 | 说明 |
|---|---|
| 1041 | 账号未开启音频审核功能(audioModerationFunctionEnable 为 N、空或其他值) |
| 30130 | 审核策略不能为空(金融版 moderationStrategy 未传或非法) |
| 30131 | 请至少开启大模型审核或应用严禁词(大模型版 moderationEnabled=Y 时 llmAuditEnabled 与 badwordEnabled 均未开启) |
