保利威文档中心

幫助中心

修改頻道觀看條件

更新時間: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

線上API呼叫

請求方式

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&timestamp=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": ""
}
联系客服,在线咨询