Polyv Help Center

Help Center

Batch Create Channels

Updated: 2023-04-04 09:31:23

Interface Description

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

Interface URL

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

Request Method

POST

Interface Constraints

  1. The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See "Get Secret Key"
timestamp true Long Current 13-digit millisecond timestamp, valid for 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server and obtain response data. See "Signature Generation Rules"

Request Body Parameter Description

Parameter Required Type Description
channels true Array Channel list, maximum 100 channels per creation See "channel field description"
channel parameter description
Parameter Required Type Description
name true String Channel name
channelPasswd false String Channel password
courseId false String Course ID
receive false String Whether it is a receiving relay channel. Leave empty or fill with other values to create a sending relay channel (Note: This parameter only takes effect when the channel relay function is enabled)
Y: Yes
N: No
autoPlay false Integer Whether to auto-play, default is 1 ** (Note: If this value is empty, the channel will use the global "Feature Switch Settings". If not empty, the channel's own "Feature Switch Settings" will be used.)**
0: Auto-play
1: Manual play
playerColor false String Player control bar color, default: #666666
scene false String Live streaming scene
alone: Event recording
ppt: Three-screen layout
topclass: Large class
seminar: Seminar
categoryId false Integer Category ID for the new channel. If not submitted, the default category is used. (Category ID can be obtained via the "Query Live Categories" interface)
subAccount false String Sub-account email. When filled, the channel will be created under this sub-account (the sub-account cannot be deleted or disabled). Currently cannot be obtained via API.

Example

http://api.polyv.net/live/v3/channel/basic/batch-create?appId=frlr1zazn3&sign=1B76E8026C5F03B92E4725D6835DA57E&timestamp=1636707112481

Request body JSON parameters:

{
    "channels": [
        {
            "name": "测试批量创建频道2(子账号)",
            "channelPasswd": "Hi826g",
            "subAccount": "test-dev@qq.com",
            "categoryId": 391352
        },
        {
            "name": "测试批量创建频道2(主账号)",
            "channelPasswd": "Hi826g",
            "autoPlay": 0,
            "playerColor": "#454545",
            "scene": "ppt",
            "categoryId": 391352
        }
    ]
}

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure See "Global Error Description"
status String Response status text information
message String Response description message. When code is 400 or 500, provides auxiliary error reason description
data Object Returns batch channel information on success See "data field description"
Data parameter description
Parameter Type Description
channels Array Array of channel content list See "channel field description"
channel parameter description
Parameter Type Description
channelId String Live channel ID
userId String POLYV user ID, consistent with the POLYV official website. Access path: Official website -> Login -> Live (Development Settings)
name String Live channel name
publisher String Host
description String Live channel description
url String Live streaming push URL
stream String Live stream name
logoImage String Player logo
logoOpacity Float Logo opacity
1: Fully opaque
0: Fully transparent
logoPosition String Logo position
tr1: Top left
tr: Top right
b1: Bottom left
br: Bottom right
logoHref String Logo click-through link
coverImage String Cover image displayed before playback
coverHref String Cover image click-through link
waitImage String Image displayed while waiting for push stream
waitHref String Click-through link for the waiting image
cutoffImage String Image displayed when stream is cut off
cutoffHref String Click-through link for the cutoff image
advertType String Pre-roll advertisement
NONE: No ad
IMAGE: Image
FLV: Video
advertDuration Integer Ad duration (seconds)
advertWidth Integer Ad area width (pixels)
advertHeight Integer Ad area height (pixels)
advertImage String Image advertisement
advertHref String Ad click-through link
advertFlvVid String Video ad ID
advertFlvUrl String Video ad link
playerColor String Player control bar color, e.g., #666666
autoPlay Boolean Whether to auto-play
warmUpFlv String Warm-up video link
passwdRestrict Boolean Viewing password restriction, requires entering a viewing password to play the stream
passwdEncrypted String Encrypted viewing password ciphertext
isOnlyAudio String Y: Audio mode
N: Normal mode
isLowLatency String Low latency
channelLogoImage String Channel icon
scene String Live streaming scene
alone: Event recording
ppt: Three-screen layout
topclass: Large class
seminar: Seminar
channelViewerPasswd String Participant password
channelPasswd String Channel password
linkMicLimit Integer Maximum number of connected microphones. -1: Use account's connected microphone limit, 0-16: Specific number of connected microphones
streamType String Live streaming method
pureRtcEnabled String Whether it is pure RTC stream pulling
Y: Yes
N: No
type String Channel type
Sending relay: transmit
Receiving relay: receive
Normal channel: normal
cnAndEnLiveEnabled String Chinese/English live room switch
Y: Enabled
N: Disabled
pushEnUrl String English push stream URL
currentTimeMillis Long Current timestamp (milliseconds)

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The HttpUtil.java and LiveSignUtil.java in the test cases are included in the downloaded file.

It is strongly recommended to use the Live Java SDK to implement API functionality. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
 * 批量创建频道
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void testBatchCreateChannels() 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/basic/batch-create";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    url = HttpUtil.appendUrl(url, requestMap);
    
    String password = getRandomString(6);
    String json = "{\"channels\":[{\"name\":\"测试批量创建频道2(子账号)\",\"channelPasswd\":\"%s\"," +
    "\"subAccount\":\"test-dev@qq.com\",\"categoryId\":391352},{\"name\":\"测试批量创建频道2(主账号)\"," +
    "\"channelPasswd\":\"%s\",\"autoPlay\":0,\"playerColor\":\"#454545\",\"scene\":\"ppt\"," +
    "\"categoryId\":391352}]}";
    json = String.format(json, password, password);
    String response = HttpUtil.postJsonBody(url, json, null);
    log.info("测试批量创建频道,返回值:{}", response);
    //do somethings
    
}

Response Example

For system global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "channels": [
            {
                "channelId": 2671471,
                "userId": "1b448be323",
                "name": "测试批量创建频道2(子账号)",
                "publisher": "主持人",
                "description": "",
                "url": "rtmp://push-d1.videocc.net/recordf/1b448be3231636707115007c115?auth_key=1636708917-0-0-355f0b98f5f93ddc588fcd7770fe07fa",
                "stream": "1b448be3231636707115007c115",
                "logoImage": "https://liveimages.videocc.net/uploaded/images/2021/04/fy3ce1e8uh.png",
                "logoOpacity": 0.37,
                "logoPosition": "tr",
                "logoHref": "",
                "coverImage": "",
                "coverHref": "",
                "waitImage": "",
                "waitHref": "",
                "cutoffImage": "",
                "cutoffHref": "",
                "advertType": "NONE",
                "advertDuration": 0,
                "advertWidth": 0,
                "advertHeight": 0,
                "advertImage": "",
                "advertHref": "",
                "advertFlvVid": "",
                "advertFlvUrl": "",
                "playerColor": "#666666",
                "autoPlay": false,
                "warmUpFlv": "",
                "passwdRestrict": false,
                "passwdEncrypted": "",
                "isOnlyAudio": "N",
                "isLowLatency": "N",
                "m3u8Url": "http://pull-d1.videocc.net/recordf/1b448be3231636707115007c115.m3u8?auth_key=1636707117-0-0-3dc1259df0643a2dc9c61c40b9d17c44",
                "m3u8Url1": "",
                "m3u8Url2": "",
                "m3u8Url3": "",
                "channelLogoImage": "https://liveimages.videocc.net/assets/wimages/pc_images/logo.png",
                "scene": "alone",
                "channelViewerPasswd": null,
                "channelPasswd": "Hi826g",
                "linkMicLimit": 16,
                "streamType": "client",
                "pureRtcEnabled": "N",
                "type": "normal",
                "cnAndEnLiveEnabled": "N",
                "pushEnUrl": null,
                "closeDanmu": "N",
                "currentTimeMillis": 1636707119516
            },
            {
                "channelId": 2671472,
                "userId": "1b448be323",
                "name": "测试批量创建频道2(主账号)",
                "publisher": "主持人",
                "description": "",
                "url": "rtmp://push-d1.videocc.net/recordf/1b448be32316367071173751967?auth_key=1636708919-0-0-2b2602020d19528b19d6374b12fe9263",
                "stream": "1b448be32316367071173751967",
                "logoImage": "https://liveimages.videocc.net/uploaded/images/2021/04/fy3ce1e8uh.png",
                "logoOpacity": 0.37,
                "logoPosition": "tr",
                "logoHref": "",
                "coverImage": "",
                "coverHref": "",
                "waitImage": "",
                "waitHref": "",
                "cutoffImage": "",
                "cutoffHref": "",
                "advertType": "NONE",
                "advertDuration": 0,
                "advertWidth": 0,
                "advertHeight": 0,
                "advertImage": "",
                "advertHref": "",
                "advertFlvVid": "",
                "advertFlvUrl": "",
                "playerColor": "#666666",
                "autoPlay": false,
                "warmUpFlv": "",
                "passwdRestrict": false,
                "passwdEncrypted": "",
                "isOnlyAudio": "N",
                "isLowLatency": "N",
                "m3u8Url": "http://pull-d1.videocc.net/recordf/1b448be32316367071173751967.m3u8?auth_key=1636707119-0-0-19617586a7f61654216cce2c4827cebc",
                "m3u8Url1": "",
                "m3u8Url2": "",
                "m3u8Url3": "",
                "channelLogoImage": "https://liveimages.videocc.net/assets/wimages/pc_images/logo.png",
                "scene": "ppt",
                "channelViewerPasswd": null,
                "channelPasswd": "Hi826g",
                "linkMicLimit": 16,
                "streamType": "client",
                "pureRtcEnabled": "N",
                "type": "normal",
                "cnAndEnLiveEnabled": "N",
                "pushEnUrl": null,
                "closeDanmu": "N",
                "currentTimeMillis": 1636707119516
            }
        ]
    }
}

Error Example

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