Create a Single Channel (Legacy)
Updated: 2024-12-16 19:20:19
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/create
Request Method
POST
Interface Constraints
- 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 not be stored 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 to obtain response data. [See Signature Generation Rules] |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| basicSetting | true | Object | Basic settings [See basicSetting Field Description] |
| authSettings | false | Array | Viewing condition settings [See authSettings Field Description] |
| playbackSetting | false | Object | Playback settings [See playbackSetting Field Description] |
| teacher | false | Object | Teacher settings [See teacher Field Description] |
| roles | false | Array | Role settings [See roles Field Description] |
basicSetting Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Channel name |
| channelPasswd | false | String | Channel password, max length 16 characters, must contain both letters and numbers |
| autoPlay | false | Integer | Auto-play 0: Do not auto-play 1: Auto-play, default 1 |
| playerColor | false | String | Player control bar color, default: #666666 |
| scene | false | String | Live streaming scenario alone: Event recording ppt: Three-screen layout topclass: Large class seminar: Seminar |
| categoryId | false | Integer | Category ID for the new channel. If not submitted, uses the default category (Category ID can be obtained via the "Query Live Categories" interface) |
| maxViewer | false | Integer | Maximum concurrent viewers, 0 and -1 mean unlimited |
| startTime | false | Long | Live start time, 13-digit millisecond timestamp |
| desc | false | String | Live stream description |
| publisher | false | String | Host |
| linkMicLimit | false | Integer | Number of people in the mic queue, max 16 (range >= -1, <= globally set mic queue limit), -1: Use globally set mic queue limit |
| pureRtcEnabled | false | String | Whether it is a low-latency live stream, default N Y: Yes N: No |
| receive | false | String | Whether it is a receiving relay channel. Leave empty or set other values for initiating relay channel (Note: The channel relay function must be enabled for this parameter to take effect) Y: Yes N: No |
| receiveChannelIds | false | String | Receiving relay channel IDs, multiple IDs separated by commas. If the receive parameter value is Y, this parameter is invalid (Note: The channel relay function must be enabled for this parameter to take effect) |
| onlyOneLiveEnabled | false | String | Whether the channel can only be streamed once, default N Y: Yes N: No |
| coverImg | false | String | Cover image URL |
| splashEnabled | false | String | Splash screen toggle, default N Y: Yes N: No |
| splashImg | false | String | Splash image URL |
| likes | false | Long | Number of likes |
| pageView | false | Long | Cumulative views |
| closeDanmu | false | String | Whether to disable the danmaku (bullet comments) feature, Y: Disable N: Do not disable |
| showDanmuInfoEnabled | false | String | Whether to display danmaku information toggle, Y: Display N: Do not display |
| subAccount | false | String | Sub-account email. If filled, the channel will be created under this sub-account (the sub-account cannot be deleted or disabled). Currently cannot be obtained via API |
authSettings Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| rank | true | Integer | Primary viewing condition is 1, secondary viewing condition is 2 |
| enabled | true | String | Whether to enable conditional viewing N: Disable Y: Enable |
| authType | false | String | pay: Paid viewing code: Verification code viewing info: Registration viewing custom: Custom authorization viewing external: External authorization viewing direct: Direct authorization viewing |
| payAuthTips | false | String | When authType is pay, this parameter is required. Welcome message title |
| price | false | Float | When authType is pay, this parameter is required. Price, in yuan |
| watchEndTime | false | String | When authType is pay, this parameter is optional. Paid validity end date, format: yyyy-MM-dd HH:mm |
| validTimePeriod | false | Integer | When authType is pay, this parameter is optional. Paid validity duration, in days. When both watchEndTime and validTimePeriod are empty, it means paid permanently valid |
| authCode | false | String | When authType is code, this parameter is required. Verification code |
| qcodeTips | false | String | When authType is code, this parameter is optional. Prompt text |
| qcodeImg | false | String | When authType is code, this parameter is optional. Official account QR code URL |
| infoFields | false | Array | When authType is info, this parameter is required. Registration viewing information, max 5 items [See infoFields Field Description] |
| externalKey | false | String | When authType is external, this parameter is required. SecretKey |
| externalUri | false | String | When authType is external, this parameter is required. Custom URL |
| externalRedirectUri | false | String | When authType is external, this parameter is optional. Redirect URL |
| customKey | false | String | When authType is custom, this parameter is required. SecretKey |
| customUri | false | String | When authType is custom, this parameter is required. Custom URL |
| directKey | false | String | When authType is direct, this parameter is required. Direct authorization SecretKey |
InfoField Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | false | String | When authType is info, this parameter is optional. Registration info name, max 8 characters |
| type | false | String | When authType is info, this parameter is required. Registration type name: Name text: Text mobile: Phone number number: Number option: Dropdown option |
| options | false | String | When authType is info, this parameter is optional. For dropdown options, the option values separated by commas. Max 8 options; each option max 8 characters |
| placeholder | false | String | When authType is info, this parameter is optional. Text input placeholder, max 8 characters |
| sms | false | String | When authType is info, this parameter is optional. SMS verification toggle, Y: Enable, N: Disable |
playbackSetting Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| globalSettingEnabled | false | String | Whether to apply global settings Y: Yes N: No |
| playbackEnabled | false | String | Playback toggle Y: Enable N: Disable |
| type | false | String | Playback method single: Single playback list: List playback |
| origin | false | String | Playback source record: Temporary storage playback: Playback list vod: VOD list |
| videoId | false | String | Video ID for single playback |
teacher Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| nickname | false | String | Teacher nickname, length 1~8 characters, default is "Teacher" |
| actor | false | String | Teacher title, length 1~8 characters, default is "Teacher" |
| passwd | false | String | Teacher password (same description as basicSetting.channelPasswd, can be omitted here) |
| avatar | false | String | Avatar image URL |
roles Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| nickname | false | String | Role nickname, length 1~8 characters |
| actor | false | String | Role title, length 1~8 characters |
| passwd | false | String | Role password |
| avatar | false | String | Avatar image URL |
| role | false | String | Role type Assistant-Assistant Guest-Guest |
Example
http://api.polyv.net/live/v3/channel/basic/create?appId=frlr1zazn3&sign=A4433D6B4C9E5F34415EBACA2F206DDE×tamp=1636706861620
Request body JSON parameters:
{
"basicSetting": {
"name": "测试子账号创建频道",
"channelPasswd": "j12dno3a12",
"maxViewer": 20,
"subAccount": "test-dev@qq.com",
"categoryId": 391352
},
"authSettings": [
{
"watchEndTime": 1616753886000,
"rank": 1,
"enabled": "Y",
"authType": "external",
"externalKey": "L0EjokKI4O",
"externalUri": "http://demo.ipolyv.cn/chenwb/live-validate.php"
}
]
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure [See Global Error Description] |
| status | String | Response status text |
| message | String | Response description, when code is 400 or 500, provides auxiliary error description |
| data | Object | On successful response, returns channel details [See data Field Description] |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Live channel ID |
| userId | String | POLYV user ID, consistent with the POLYV official website. Path: Official website -> Login -> Live (Development Settings) |
| name | String | Live channel name |
| publisher | String | Host |
| description | String | Live channel description |
| url | String | Live stream 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 URL |
| coverImage | String | Cover image displayed before playback |
| coverHref | String | Cover image click-through URL |
| waitImage | String | Image displayed while waiting for stream push |
| waitHref | String | Click-through URL for the waiting image |
| cutoffImage | String | Image displayed when stream is cut off |
| cutoffHref | String | Click-through URL for the cutoff image |
| advertType | String | Pre-roll ad 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 ad |
| advertHref | String | Ad click-through URL |
| advertFlvVid | String | Video ad ID |
| advertFlvUrl | String | Video ad URL |
| playerColor | String | Player control bar color, e.g., #666666 |
| autoPlay | Boolean | Whether to auto-play |
| warmUpFlv | String | Warm-up video URL |
| 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 scenario alone: Event recording ppt: Three-screen layout topclass: Large class seminar: Seminar |
| channelViewerPasswd | String | Participant password |
| channelPasswd | String | Channel password |
| linkMicLimit | Integer | Mic queue limit -1: Use account mic queue limit 0-16: Number of people in the mic queue |
| streamType | String | Live streaming method client: Client push pull: Pull stream thirdpull: Third-party pull stream disk: Pseudo-live audio: Audio live stream |
| pureRtcEnabled | String | Whether it is a low-latency live stream, default N Y: Yes N: No |
| type | String | Channel type Initiating relay: transmit Receiving relay: receive Normal channel: normal |
| cnAndEnLiveEnabled | String | Chinese/English live room toggle Y: Enable N: Disable |
| pushEnUrl | String | English push 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. 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 for API function integration. 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 testBasicCreate() 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/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 json = "{\"basicSetting\":{\"name\":\"测试子账号创建频道\",\"channelPasswd\":\"j12dno3a12\",\"maxViewer\":20," +
"\"subAccount\":\"test-dev@qq.com\",\"categoryId\":391352}," +
"\"authSettings\":[{\"watchEndTime\":1616753886000,\"rank\":1,\"enabled\":\"Y\"," +
"\"authType\":\"external\",\"externalKey\":\"L0EjokKI4O\",\"externalUri\":\"http://demo.polyv" +
".net/chenwb/live-validate.php\"}]}";
String response = HttpUtil.postJsonBody(url, json, null);
log.info("测试创建单个频道,返回值:{}", response);
//do somethings
}
Response Example
For system-wide global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "",
"data": {
"channelId": 2671450,
"userId": "1b448be323",
"name": "测试子账号创建频道",
"publisher": null,
"description": "",
"url": "rtmp://push-d1.videocc.net/recordf/1b448be3231636706865463d4d0?auth_key=1636708667-0-0-a1f63391368503d2c72caa4021588a99",
"stream": "1b448be3231636706865463d4d0",
"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/1b448be3231636706865463d4d0.m3u8?auth_key=1636706867-0-0-020d65f5b0ead855eda5220abeb60278",
"m3u8Url1": "",
"m3u8Url2": "",
"m3u8Url3": "",
"channelLogoImage": null,
"scene": "alone",
"channelViewerPasswd": null,
"channelPasswd": "j12dno3a12",
"linkMicLimit": 16,
"streamType": "client",
"pureRtcEnabled": "N",
"type": "normal",
"cnAndEnLiveEnabled": null,
"pushEnUrl": null,
"closeDanmu": "N",
"currentTimeMillis": 1636706867876
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
