保利威文档中心

帮助中心

修改默认模板-观看条件

更新时间:2024-12-16 11:04:46

接口描述

1、修改默认模板-观看条件
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

接口URL

http://api.polyv.net/live/v4/global/auth/update

在线API调用

请求方式

POST

接口约束

1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看

2、请求体数组第一个为主要观看条件,第二个为次要观看条件,必须传两个

请求参数描述

参数名 必选 类型 说明
appId true String 账号appId【详见获取密钥
sign true String 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则
timestamp true String 当前13位毫秒级时间戳,3分钟内有效

请求体参数描述

参数名 必选 类型 说明
authEnabled true String 授权开关值,开启时授权才会生效,Y:开启,N:关闭
authType true String 授权类型
code:验证码观看
pay:付费观看
phone:白名单观看
info:登记观看
custom:自定义授权观看
external:外部授权观看
direct:独立授权观看
public: 公开观看
wx:微信授权观看
wxAuthExpireValue false String authType为wx时,对应的微信授权值,支持以d和h为单位,例如3d表示3天,3h表示3小时
whiteListEntryText false String 当authType为phone时,设置参数,必填。白名单入口文本,不超过64字符
whiteListInputTips false String 当authType为phone时,设置参数,非必填。白名单输入提示,不超过64字符
authTips false String 当authType为phone时,设置参数,非必填。白名单欢迎标题,不超过20字符
payAuthTips false String 当authType为pay时,设置参数,必填。付费观看欢迎标题,不超过64字符
price false Float 当authType为pay时,设置参数,必填。价格,单位为元
trialWatchEnabled false String 当authType为pay时,设置参数,必填。允许试看开关,Y:开启,N:关闭
trialWatchEndTime false String 当authType为pay时,设置参数,非必填。试看有效截止日期,格式:yyyy-MM-dd HH:mm:ss
trialWatchTime false Integer 当authType为pay时,设置参数,trialWatchEnabled为Y时必填。试看时长,单位:分钟
validTimePeriod false Integer 当authType为pay时,设置参数,非必填。付费有效时长,单位天。当watchEndTime和validTimePeriod都为空时,表示付费永久有效
watchEndTime false String 当authType为pay时,设置参数,非必填。付费有效截止日期,格式:yyyy-MM-dd HH:mm
authCode false String 当authType为code时,设置参数,必填。验证码,不超过8字符
codeAuthTips false String 当authType为code时,设置参数,必填。验证码,不超过20字符
qcodeImg false String 当authType为code时,设置参数,非必填。公众号二维码地址,http链接,最长256位
qcodeTips false String 当authType为code时,设置参数,非必填。提示文案,不超过30字符
infoAuthTips false String 当authType为info时,设置参数,必填。登记观看欢迎标题,不超过64字符
infoDesc false String 当authType为info时,设置参数,非必填。登记观看提示信息,不超过100字符
infoFields false Array 当authType为info时,设置参数,必填。登记观看信息,上限为10个【详见InfoFields参数描述
customKey false String 当authType为custom时,设置参数,必填。自定义授权Key,不超过64字符
customUri false String 当authType为custom时,设置参数,必填。自定义授权Url,不超过128字符
externalEntryText false String 当authType为external时,设置参数,必填。外部授权入口文本,不超过24字符
externalKey false String 当authType为external时,设置参数,必填。外部授权Key,不超过64字符
externalRedirectUri false String 当authType为external时,设置参数,非必填。外部授权失败Url,不超过350字符
externalUri false String 当authType为external时,设置参数,必填。外部授权Url,不超过128字符
directKey false String 当authType为direct时,设置参数,必填。独立授权Key,不超过64字符
privacyParamEnabled false String 当authType为code、phone、info时,必填,隐私声明开关,Y:开启,N:关闭
privacyParam false String 当authType为code、phone、info时,隐私声明开关开启时,必填,隐私声明数据
expectedArrivalEnabled false String 当authType为phone时使用,设置到课名单开关,Y:开启,N:关闭
onceWhitelistEnabled false String 白名单不允许重复使用,默认为N,Y:是、N:否

InfoFields参数描述

参数名 必选 类型 说明
name false String 登记信息名,最多为8字符
options false String 当authType为info时,设置参数,非必填。下拉选项时,下拉的选项值,以英文逗号分割。选项个数上限为8个;选项内容最多为8字符
placeholder false String 文本框输入提示,最多为8字符
smsEnabled false String 短信验证,Y:开启,N:关闭
type false String 当authType为info时,非必填,登记类型,
name:姓名,
text:文本,
mobile:手机号,
number:数字,
option:下拉选项

示例

http://api.polyv.net/live/v4/global/auth/update?appId=frlr1zazn3&sign=E864B4E2758C70EC88851094F5041991&timestamp=1680502739391

请求体json参数:

[
    {
        "customKey": "12121212",
        "authEnabled": "Y",
        "customUri": "http://baidu.com",
        "authType": "custom"
    },
    {
        "whiteListEntryText": "白名单入口文本",
        "privacyParam": "隐私声明数据",
        "authEnabled": "Y",
        "privacyParamEnabled": "Y",
        "authType": "phone",
        "authTips": "123"
    }
]

响应参数描述

参数名 类型 说明
code Integer 状态码,与 http 状态码相同,用于确定基本的响应状态
data Object 成功响应的数据
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 authUpdateTest() 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/global/auth/update";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    
    List<Map<String, Object>> authList = new ArrayList<>();
    Map<String, Object> jsonMap = new HashMap<>();
    jsonMap.put("authType","custom");
    jsonMap.put("authEnabled","Y");
    jsonMap.put("customKey","12121212");
    jsonMap.put("authType","custom");
    jsonMap.put("customUri","http://baidu.com");
    authList.add(jsonMap);
    jsonMap = new HashMap<>();
    jsonMap.put("authType","phone");
    jsonMap.put("authEnabled","Y");
    jsonMap.put("whiteListEntryText","白名单入口文本");
    jsonMap.put("authTips","123");
    jsonMap.put("privacyParamEnabled","Y");
    jsonMap.put("privacyParam","隐私声明数据");
    authList.add(jsonMap);
    
    url = HttpUtil.appendUrl(url, requestMap);
    String response = HttpUtil.postJsonBody(url, JSON.toJSONString(authList), null);
    
    log.info("测试修改默认模板-观看条件成功:{}", response);
    //do somethings
    
}

响应示例

系统全局错误说明详见全局错误说明

成功示例

{
  "code": 200,
  "status": "success",
  "requestId": "66d3d82b356e457098bbe15a659a322f.6025.16805027480479129",
  "data": null,
  "success": true
}

异常示例

{
    "code": 400,
    "status": "error",
    "requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
    "error": {
        "code": 20001,
        "desc": "application not found."
    },
    "success": false
}
联系客服,在线咨询