保利威文档中心

幫助中心

取得頻道的 RTMP 拉流位址

更新時間:2022-09-02 18:08:07

介面 URL

https://api.polyv.net/live/v3/channel/monitor/rtmp-pull-url

介面說明

1、接口用于获取频道获取频道的rtmp拉流地址
2、接口支持https

回傳結果格式

JSON

請求方式

GET

請求參數

參數名 必填 類型 說明
appId string 從 API 設定中取得,在直播系統登記的 appId
timestamp long 目前 13 位毫秒級時間戳,3 分鐘內有效
sign String 簽名,為 32 位大寫的 MD5 值,產生簽名的 appSecret 金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有 API 都必須透過客戶自己的伺服器中轉呼叫 POLYV 伺服器取得回應資料【詳見簽名產生規則
channelId int 頻道號碼
day int 有效期限天數,如:1 表示從目前時間算起一天內有效

回應成功 JSON 範例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data":  "rtmp://pull-d1.videocc.net/recordf/4f57ea01de16002237826505a7b?auth_key=1602645379-0-0-5d6bc0d1ea472b161ee9e0ea3646bess"
}

回應失敗 JSON 範例:

未輸入 appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId 不正確

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

時間戳錯誤

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

簽名錯誤

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

非法的存取

{
    "code": 400,
    "data": "",
    "message": "forbidden",
    "status": "error"
}

欄位說明

參數名 說明
code 回應代碼,成功為 200,失敗為 400,簽名錯誤為 403,異常錯誤 500
status 成功為 success,失敗為 error
message 錯誤時的錯誤提示訊息
data 成功資料

Java 請求範例

public static void test() {
        String url = "https://api.polyv.net/live/v3/channel/monitor/rtmp-pull-url";
        // 用户对应的appId和加密串
        String appId = "xxxxxxxxx";
        String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
        int channelId = 10001;
        Map<String, String> params = new HashMap<>();
        params.put("channelId", channelId);
        params.put("day", 1);
        PolyvTool.setLiveSign(params, appId, appSecret);
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance()
                .sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
        System.out.println(content);
    }
联系客服,在线咨询