保利威文档中心

幫助中心

頻道狀態驗證

更新時間:2022-09-02 09:54:31

介面描述

1、查询频道合法状态
2、接口支持https协议

介面URL

http://api.polyv.net/live/v4/channel/status-valid

請求方式

GET

介面限制

1、介面呼叫有頻率限制,詳細請查看

請求參數描述

參數名 必選 類型 說明
appId true String 帳號appId【詳見取得金鑰
timestamp true Long 目前13位毫秒級時間戳記,3分鐘內有效
sign true String 簽名,為32位大寫的MD5值【詳見簽名產生規則
channels true String 頻道號,多個使用英文逗號分開,最多100個,例如:100000,100001

範例

http://api.polyv.net/live/v4/channel/status-valid?channels=1965681%2C2272665%2C3297504&appId=frlr1zazn3&sign=F8BDEF93ED3CD6EDEEFB399187D97582&timestamp=1662083490979

回應參數描述

參數名 類型 說明
code Integer 狀態碼,與 http 狀態碼相同,用於確定基本的回應狀態
status String 回應結果,由業務決定,成功回傳success,失敗回傳error
success Boolean 是否成功回應
requestId String 請求ID,每次請求產生的唯一 UUID,僅可用於排查、除錯,不應該和業務掛鉤
error Object 狀態碼非200時的錯誤資訊【詳見Error欄位描述
data Object 【詳見data欄位說明

Error參數描述

參數名 類型 說明
code Integer 錯誤代碼,用於確定具體的錯誤原因
desc String 錯誤描述,與 error.code 對應

data參數描述

參數名 類型 說明
channels Array 頻道列表【詳見channels欄位描述

channels參數描述

參數名 類型 說明
channelId Integer 頻道號
delete Integer 頻道是否已刪除
1:已刪除
0:未刪除
currentUser Integer 是否屬於目前使用者
1:是
0:否

Java請求範例

快速接入基礎代碼請下載相關依賴原始碼點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試案例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。

強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、例外處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。

private static final Logger log = LoggerFactory.getLogger(GroupTestLive.class);
/**
 * 频道状态验证
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetChannelStatusValid() 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/v4/channel/status-valid";
    String channels = "1965681,2272665,3297504";
    
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("channels", channels);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url, requestMap);
    log.info("测试频道状态验证,返回值:{}", response);
    //do somethings
    
}

回應範例

系統全域錯誤說明詳見全域錯誤說明

成功範例

{
    "code": 200,
    "status": "success",
    "requestId": "522451e702a4454dbb1a972abd4d4b71.62.16618407903140831",
    "data": {
        "channels": [
            {
                "channelId": 1965681,
                "delete": 0,
                "currentUser": 1
            },
            {
                "channelId": 2272665,
                "delete": 1,
                "currentUser": 0
            },
            {
                "channelId": 3297504,
                "delete": 1,
                "currentUser": 1
            }
        ]
    },
    "success": true
}

異常範例

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