保利威文档中心

幫助中心

批量建立接收轉播的頻道

更新時間:2023-04-04 09:31:23

介面說明

1、根据发起转播的频道,批量创建接收转播的频道
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

介面URL

http://api.polyv.net/live/v3/channel/transmit/batch-create

請求方式

POST

介面限制

1、介面同時支援HTTP、HTTPS,建議使用HTTPS以確保介面安全,介面呼叫有頻率限制,詳細請查看

2、最大支援一次性建立100個接收轉播的頻道,發起轉播的頻道最多支援500個接收轉播的頻道

請求參數說明

參數名 必填 類型 說明
appId true String 帳號appId【詳見取得金鑰
timestamp true Long 目前13位毫秒級時間戳,3分鐘內有效
sign true String 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則
channelId true String 頻道號(發起轉播的頻道號)

請求體參數說明

類型 必填 說明
Array true 接收轉播的頻道名稱列表,例:["保利威接收轉播測試頻道"]

範例

http://api.polyv.net/live/v3/channel/transmit/batch-create?appId=frlr1zazn3&sign=D02FA683640135D843D485EE84F6632A&channelId=2588188&timestamp=1632809855078

請求體json參數:

[
    "接收转播频道1",
    "接收转播频道2"
]

回應參數說明

參數名 類型 說明
code Integer 回應狀態碼,200為成功返回,非200為失敗【詳見全域錯誤說明
status String 回應狀態文字資訊
message String 回應描述資訊,當code為400或500時,輔助描述錯誤原因
data Array 成功建立的接收轉播的頻道資訊列表【詳見ChannelInfo欄位說明

ChannelInfo參數說明

參數名 類型 說明
channelId Integer 頻道號
name String 頻道名稱
channelPasswd String 頻道密碼
authType String 頻道觀看條件
playBackEnabled String 頻道是否開啟回放,Y:開啟,N:關閉
streamType String 頻道推流方式
debugEnabled String 頻道是否開啟除錯,Y:開啟,N:關閉
stream String 頻道串流名稱
status String 頻道狀態
categoryId Integer 頻道所在分類Id
categoryName String 頻道所在分類名稱
isSmallClass String 頻道是否為小班課,Y:開啟,N:關閉
newScene String 頻道直播場景,與發起轉播的頻道一致
template String 頻道直播模板,與發起轉播的頻道一致
createdTime Long 頻道建立時間
coverImage String 頻道封面圖片
type String 頻道類型,transmit:發起轉播,normal:普通的頻道,receive:接收轉播
startTime Long 頻道開始時間
publisher String 頻道主持人
splashImg String 頻道引導圖圖片位址
splashEnabled String 頻道引導圖開關,Y:開啟,N:關閉
pureRtcEnabled String 頻道無延遲直播開關,Y:開啟,N:關閉
roomIds String 頻道分房間資訊,沒有則返回null

Java請求範例

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

    @Test
    public void testBatchCreateTransmitChannel() 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/transmit/batch-create";
        String channelId = "2588188";
        
        //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);
        
        List<String> list = new ArrayList<>();
        list.add("接收转播频道1");
        list.add("接收转播频道2");
        
        String json= JSON.toJSONString(list);
        String response = HttpUtil.postJsonBody(url, json,null);
        log.info("测试修改频道信息,返回值:{}", response);
    }

回應範例

成功範例

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "channelId": 2588440,
            "name": "接收转播频道1",
            "channelPasswd": "8pWtmd",
            "authType": "phone",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "N",
            "stream": "1b448be3231632809860172afac",
            "status": "客户端推流/直播结束",
            "categoryId": 340019,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "newScene": null,
            "template": null,
            "createdTime": 1632809860000,
            "appId": null,
            "coverImage": "",
            "type": "receive",
            "startTime": null,
            "publisher": "主持人",
            "channelLogo": null,
            "splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null,
            "transmitType": null,
            "rtcType": null,
            "channelSessionId": null,
            "lastPushStreamTime": null
        },
        {
            "channelId": 2588441,
            "name": "接收转播频道2",
            "channelPasswd": "8pWtmd",
            "authType": "phone",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "N",
            "stream": "1b448be323163280986017418fb",
            "status": "客户端推流/直播结束",
            "categoryId": 340019,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "newScene": null,
            "template": null,
            "createdTime": 1632809860000,
            "appId": null,
            "coverImage": "",
            "type": "receive",
            "startTime": null,
            "publisher": "主持人",
            "channelLogo": null,
            "splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null,
            "transmitType": null,
            "rtcType": null,
            "channelSessionId": null,
            "lastPushStreamTime": null
        }
    ]
}

異常範例

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
联系客服,在线咨询