保利威文档中心

幫助中心

修改預設模板-觀看條件

更新時間: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
}
联系客服,在线咨询