Polyv Help Center

Help Center

Modify Default Template - Viewing Conditions

Updated: 2024-12-16 11:04:46

API Description

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

API URL

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

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. The first element in the request body array is the primary viewing condition, and the second is the secondary viewing condition. Both must be provided.

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details on obtaining keys
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules
timestamp true String Current 13-digit millisecond timestamp, valid for 3 minutes

Request Body Parameter Description

Parameter Required Type Description
authEnabled true String Authorization switch value. Authorization takes effect only when enabled. Y: Enable, N: Disable
authType true String Authorization type
code: Verification code viewing
pay: Paid viewing
phone: Whitelist viewing
info: Registration viewing
custom: Custom authorization viewing
external: External authorization viewing
direct: Independent authorization viewing
public: Public viewing
wx: WeChat authorization viewing
wxAuthExpireValue false String When authType is wx, the corresponding WeChat authorization value. Supports units d and h, e.g., 3d for 3 days, 3h for 3 hours
whiteListEntryText false String When authType is phone, this parameter is required. Whitelist entry text, max 64 characters
whiteListInputTips false String When authType is phone, this parameter is optional. Whitelist input prompt, max 64 characters
authTips false String When authType is phone, this parameter is optional. Whitelist welcome title, max 20 characters
payAuthTips false String When authType is pay, this parameter is required. Paid viewing welcome title, max 64 characters
price false Float When authType is pay, this parameter is required. Price, in yuan
trialWatchEnabled false String When authType is pay, this parameter is required. Trial watch switch, Y: Enable, N: Disable
trialWatchEndTime false String When authType is pay, this parameter is optional. Trial watch valid end date, format: yyyy-MM-dd HH:mm:ss
trialWatchTime false Integer When authType is pay, this parameter is required if trialWatchEnabled is Y. Trial watch duration, in minutes
validTimePeriod false Integer When authType is pay, this parameter is optional. Paid validity period, in days. If both watchEndTime and validTimePeriod are empty, the payment is valid permanently
watchEndTime false String When authType is pay, this parameter is optional. Paid valid end date, format: yyyy-MM-dd HH:mm
authCode false String When authType is code, this parameter is required. Verification code, max 8 characters
codeAuthTips false String When authType is code, this parameter is required. Verification code, max 20 characters
qcodeImg false String When authType is code, this parameter is optional. Official account QR code URL, http link, max 256 characters
qcodeTips false String When authType is code, this parameter is optional. Prompt text, max 30 characters
infoAuthTips false String When authType is info, this parameter is required. Registration viewing welcome title, max 64 characters
infoDesc false String When authType is info, this parameter is optional. Registration viewing prompt message, max 100 characters
infoFields false Array When authType is info, this parameter is required. Registration viewing information, max 10 items See InfoFields parameter description
customKey false String When authType is custom, this parameter is required. Custom authorization Key, max 64 characters
customUri false String When authType is custom, this parameter is required. Custom authorization URL, max 128 characters
externalEntryText false String When authType is external, this parameter is required. External authorization entry text, max 24 characters
externalKey false String When authType is external, this parameter is required. External authorization Key, max 64 characters
externalRedirectUri false String When authType is external, this parameter is optional. External authorization failure URL, max 350 characters
externalUri false String When authType is external, this parameter is required. External authorization URL, max 128 characters
directKey false String When authType is direct, this parameter is required. Independent authorization Key, max 64 characters
privacyParamEnabled false String When authType is code, phone, or info, this parameter is required. Privacy statement switch, Y: Enable, N: Disable
privacyParam false String When authType is code, phone, or info, this parameter is required if the privacy statement switch is enabled. Privacy statement data
expectedArrivalEnabled false String Used when authType is phone. Expected arrival list switch, Y: Enable, N: Disable
onceWhitelistEnabled false String Whitelist cannot be reused. Default is N, Y: Yes, N: No

InfoFields Parameter Description

Parameter Required Type Description
name false String Registration field name, max 8 characters
options false String When authType is info, this parameter is optional. Dropdown option values, separated by commas. Max 8 options; each option max 8 characters
placeholder false String Text input prompt, max 8 characters
smsEnabled false String SMS verification, Y: Enable, N: Disable
type false String When authType is info, this parameter is optional. Registration type,
name: Name,
text: Text,
mobile: Phone number,
number: Number,
option: Dropdown option

Example

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

Request body JSON parameters:

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

Response Parameter Description

Parameter Type Description
code Integer Status code, same as HTTP status code, used to determine the basic response status
data Object Data for a successful response
error Object Error information when status code is not 200 See Error parameter description
requestId String Request ID, a unique UUID generated for each request, used only for troubleshooting and debugging, not for business logic
status String Response result, determined by business logic. Returns success on success, error on failure
success Boolean Whether the response was successful

Error Parameter Description

Parameter Type Description
code Integer Error code, used to identify the specific error reason
desc String Error description, corresponding to error.code

Java Request Example

For quick integration of the base 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. The test cases include HttpUtil.java and LiveSignUtil.java, both included in the download file.

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

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
    
}

Response Example

For global system error descriptions, see Global Error Description

Success Example

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

Error Example

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