保利威文档中心

幫助中心

批量建立轉播子頻道介面

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

介面URL

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

介面說明

1、批量创建转播子频道
2、一次性最大支持创建100个子频道,转播子频道上限500个
3、接口支持https

支援格式

JSON

請求方式

POST

請求數限制

TRUE

請求參數

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

請求體body參數

請求body中的參數為字串陣列,字串名稱為將要建立接收轉播的頻道名稱,最多一次建立支援100個頻道 上面的請求參數需要放在query或表單中,請求體參數需要放在請求體中,不支援放在表單或query參數

[
    "接收转播频道01",
    "接收转播频道02",
    "接收转播频道03",
    "接收转播频道04"
]

回應成功JSON範例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "channelId": 2041139,
            "name": "接收转播频道01",
            "channelPasswd": "xxxx",
            "authType": "none",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "Y",
            "stream": "ee7fe7fbda1607414643915af33",
            "status": "客户端推流/直播结束",
            "categoryId": 177474,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "createdTime": 1607414644000,
            "appId": null,
            "coverImage": null,
            "type": "receive",
            "startTime": 1598630400000,
            "publisher": "666666",
            "channelLogo": null,
            "splashImg": null,
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null
        },
        {
            "channelId": 2041140,
            "name": "接收转播频道02",
            "channelPasswd": "xxxx",
            "authType": "none",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "Y",
            "stream": "ee7fe7fbda160741464391432a6",
            "status": "客户端推流/直播结束",
            "categoryId": 177474,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "createdTime": 1607414644000,
            "appId": null,
            "coverImage": null,
            "type": "receive",
            "startTime": 1598630400000,
            "publisher": "666666",
            "channelLogo": null,
            "splashImg": null,
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null
        }
    ]
}

回應失敗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": 403,
    "status": "error",
    "message": "illegal channel id: 1779742",
    "data": ""
}

請求體沒有參數

{
    "code": 400,
    "status": "error",
    "message": "request body is not empty or lost params",
    "data": ""
}

請求體陣列超過100

{
    "code": 400,
    "status": "error",
    "message": "param length is incorrect:body array size",
    "data": ""
}

轉播子頻道超過500

{
    "code": 400,
    "status": "error",
    "message": "transmit channel number limit: 500",
    "data": ""
}

未開通轉播

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

頻道數超過上限

{
    "code": 400,
    "status": "error",
    "message": "channel count reached the limit",
    "data": ""
}

欄位說明

參數名 類型 說明
code int 回應代碼,成功為200,失敗為400,簽名錯誤為401,異常錯誤500
status string 成功為success,失敗為error
message string 錯誤時為錯誤提示訊息
data array 回應結果集
data[0].channelId int 頻道號
data[0].name string 頻道名稱
data[0].channelPasswd string 頻道密碼
data[0].authType string 頻道校驗類型
data[0].playBackEnabled string 頻道是否開啟回放,Y:開啟,N:關閉
data[0].streamType string 頻道推流方式
data[0].debugEnabled string 頻道是否開啟除錯,Y:開啟,N:關閉
data[0].stream string 頻道流名
data[0].status string 頻道狀態
data[0].categoryId int 頻道所在目錄Id
data[0].categoryName string 頻道所在目錄名稱
data[0].isSmallClass string 頻道是否為小班課,Y:開啟,N:關閉
data[0].scene string 頻道場景,ppt:三分屏,alone:活動直播,topclass:大班課,seminar:研討會
data[0].createdTime long 頻道建立時間
data[0].appId string 暫時不回傳:null
data[0].coverImage string 頻道封面圖片
data[0].type string 頻道類型,transmit:發起轉播,normal:普通的頻道,receive:接收轉播
data[0].startTime long 頻道開始時間
data[0].publisher string 頻道主持人
data[0].channelLogo string 暫時不回傳:null
data[0].splashImg string 頻道引導圖圖片地址
data[0].splashEnabled string 頻道引導圖開關,Y:開啟,N:關閉
data[0].pureRtcEnabled string 頻道無延遲直播開關,Y:開啟,N:關閉
data[0].watchTimes string 暫時不回傳:null
data[0].roomIds string 頻道分房間資訊,沒有為null

Java請求範例

public static void main(String[] args) {
        String url = "http://api.polyv.net/live/v3/channel/transmit/batch-create";
        // 用户对应的appId和加密串
        String appId = "xxxxxxxxx";
        String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
        Map<String, String> params = new HashMap<>();
        params.put("channelId", "0000000");
        PolyvTool.setLiveSign(params, appId, appSecret);
        // 调用Polyv的httpClient工具类发送请求
        String body = "[\"接收转播频道01\",\"接收转播频道02\"]";
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance()
                .sendHttpPostJson(url + "?" + PolyvTool.mapJoinNotEncode(params), body, null);
        System.out.println(content);
    }
联系客服,在线咨询