修改频道观看条件
更新时间:2025-05-27 11:08:57
接口描述
1、修改频道或通用设置的观看条件(旧版直播后台-通用设置-观看条件)
2、主要观看条件为关闭时,次要观看条件不能为打开,否则返回参数错误
3、主要观看条件和次要观看条件为相同时,不能够同时打开,否则返回参数错误
4、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
5、接口支持https协议
接口URL
http://api.polyv.net/live/v3/channel/auth/update
请求方式
POST
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| appId | true | String | 账号appId【详见获取密钥】 |
| timestamp | true | Long | 当前13位毫秒级时间戳,3分钟内有效 |
| sign | true | String | 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则】 |
| channelId | false | String | 频道号,不传为通用设置 |
请求体参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| authSettings | true | Array | 观看条件设置 【详见authSettings字段说明】 |
authSettings字段说明
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| rank | true | Integer | 主要观看条件为1,次要观看条件为2 |
| enabled | true | String | 是否开启条件观看 N:关闭 Y:开启 |
| authType | false | String | pay:付费观看 code:验证码观看 phone:白名单观看 注:需确认对应rank的白名单是否存在,否则需要先调用增加频道单个白名单新增再设置观看条件 info:登记观看 custom:自定义授权观看 external:外部授权观看 direct:独立授权观看 public: 公开观看 wx:微信授权观看 |
| wxAuthExpireValue | false | String | authType为wx时,对应的微信授权值,支持以d和h为单位,例如3d表示3天,3h表示3小时 |
| payAuthTips | false | String | 当authType为pay时,设置参数,必填。欢迎语标题 |
| payEntryText | false | String | 当authType为pay时,入口文本 |
| price | false | Float | 当authType为pay时,设置参数,必填。价格,单位为元 |
| watchEndTime | false | String | 当authType为pay时,设置参数,非必填。付费有效截止日期,格式:yyyy-MM-dd HH:mm |
| validTimePeriod | false | Integer | 当authType为pay时,设置参数,非必填。付费有效时长,单位天。当watchEndTime和validTimePeriod都为空时,表示付费永久有效 |
| authCode | false | String | 当authType为code时,设置参数,必填。验证码 |
| qcodeTips | false | String | 当authType为code时,设置参数,非必填。提示文案 |
| qcodeImg | false | String | 当authType为code时,设置参数,非必填。公众号二维码地址 |
| authTips | false | String | 当authType为phone时,设置参数,非必填。提示文案 |
| infoFields | false | Array | 当authType为info时,设置参数,必填。登记观看信息,上限为5个【详见infoFields字段说明】 |
| infoAuthTips | false | String | 当authType为info时,设置参数,非必填。欢迎标题 |
| infoDesc | false | String | 当authType为info时,设置参数,非必填。提示信息 |
| infoEntryText | false | String | 当authType为info时,设置参数,非必填。入口文本 |
| externalKey | false | String | 当authType为external时,设置参数,必填。SecretKey |
| externalUri | false | String | 当authType为external时,设置参数,必填。自定义url |
| externalRedirectUri | false | String | 当authType为external时,设置参数,非必填。跳转地址 |
| externalEntryText | false | String | 当authType为external时,入口文本 |
| externalButtonEnabled | false | String | 当authType为external时,设置参数,非必填.登录按钮。Y为开启,N为关闭。开启后用户访问链接时,引导页面将显示登录按钮 |
| customKey | false | String | 当authType为custom时,设置参数,必填。SecretKey |
| customUri | false | String | 当authType为custom时,设置参数,必填。自定义url |
| directKey | false | String | 当authType为direct时,设置参数,必填。独立授权SecretKey |
| directKey | false | String | 当authType为direct时,设置参数,必填。独立授权SecretKey |
| privacyStatus | false | String | Y/N 隐私声明开关 |
| privacyContent | false | String | 隐私内容,支持富文本 |
| onceWhitelistEnabled | false | String | 白名单不允许重复使用,默认为N,Y:是、N:否 |
| expectedArrivalEnabled | false | String | 白名单观看到勤名单开关,Y-开, N-关,默认为N |
| inviteWatchAuditEnabled | false | String | 邀请观看审核开关,Y-开, N-关,默认为N |
| codeAuthTips | false | String | 密码观看条件提示信息 |
| codeEntryText | false | String | 密码观看入口文本 |
| whiteListInputTips | false | String | 白名单观看输入提示 |
| whiteListEntryText | false | String | 白名单观看入口文案 |
| false | String | ||
| false | String |
infoFields字段说明
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| name | false | String | 当authType为info时,设置参数,非必填。登记信息名,最多为20字符 |
| type | false | String | 当authType为info时,设置参数,必填。登记类型 name:姓名 text:文本 mobile:手机号码 number:数字 option:下拉选项 |
| options | false | String | 当authType为info时,设置参数,非必填。下拉选项时,下拉的选项值,以英文逗号分割。选项个数上限为50个;选项内容最多为30字符 |
| placeholder | false | String | 当authType为info时,设置参数,非必填。文本框输入提示,最多为50字符 |
| sms | false | String | 当authType为info时,设置参数,非必填。短信验证开关,Y:开启,N:关闭 |
示例
http://api.polyv.net/live/v3/channel/auth/update?appId=frlr1zazn3&sign=E2B692768C6F467B1228B5876625B71E&channelId=2191532×tamp=1621843761626
请求体参数
{
"authSettings": [{
"rank": 1,
"enabled": "Y",
"authType": "pay",
"payAuthTips": "给钱才能看",
"price": "0.01",
"watchEndTime": null,
"validTimePeriod": null
}, {
"rank": 2,
"enabled": "N"
}]
}
响应参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 响应状态码,200为成功返回,非200为失败【详见全局错误说明】 |
| status | String | 响应状态文本信息 |
| message | String | 响应描述信息,当code为400或者500的时候,辅助描述错误原因 |
| data | String | 成功时为true,错误时为空 |
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(WatchConditionTest.class);
/**
* 修改频道观看条件
* @throws IOException
*/
@Test
public void testSetWatchCondition() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v3/channel/auth/update";
String channelId = "2191532";
String body = "{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"},{\"rank\":2,\"enabled\":\"N\"}]}";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, body, null);
log.info("测试修改频道观看条件接口返回值:{}",response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
异常示例
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
