Batch Create Roles
API Description
1、批量创建角色,角色包括Guest(嘉宾)、Assistant(助教)
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/account/batch-create
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Each live channel can create up to 150 teaching assistants, with a maximum of 16 guests.
Creating a guest requires setting the channel's co-streaming user count and enabling the co-streaming feature.
Request Parameters Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details on obtaining keys |
| 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 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 for response data. See signature generation rules |
| channelId | true | String | Channel ID |
Request Body Parameters Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| passwd | false | String | Role password |
| role | false | String | Role type, defaults to assistant. Assistant: Teaching Assistant, Guest: Guest |
| nickname | false | String | Nickname of the created assistant or guest |
| actor | false | String | Title of the created assistant or guest |
| avatar | false | String | Avatar of the created assistant or guest |
Example
http://api.polyv.net/live/v3/channel/account/batch-create?appId=frlr1zazn3&sign=7D0C4520C6968C948EFA7B5B912FB979&channelId=2191569×tamp=1621841813383
Request Body Parameters
[{
"role": "Guest",
"nickname": "嘉宾",
"passwd": 123456
},
{
"role": "Assistant",
"nickname": "助教",
"passwd": 123456
}
]
Response Parameters 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 |
| message | String | Response description. When code is 400 or 500, provides additional error details. |
| data | Array | Returns role information on success. See data field description |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| account | String | Assistant/Guest account |
| userId | String | POLYV user ID, consistent with the Polyv official website. Access path: Official Website -> Login -> Live (Developer Settings) |
| channelId | String | Channel ID |
| passwd | String | Role password |
| nickname | String | Role name |
| stream | String | Role stream name (invalid when used alone) |
| status | String | Role status |
| createdTime | Long | Role creation time, 13-digit millisecond timestamp |
| lastModified | Long | Role last modification time, 13-digit millisecond timestamp |
| channelSessionId | String | Session ID |
| sort | Integer | Channel role sequence number |
| avatar | String | Role avatar |
| actor | String | Title of the created assistant or guest |
| pageTurnEnabled | String | Assistant page turning permission (only one assistant can have this) Y: Enabled N: Disabled |
| notifyEnabled | String | Announcement publishing permission Y: Enabled N: Disabled |
| checkinEnabled | String | Check-in permission Y: Enabled N: Disabled |
| voteEnabled | String | Voting initiation permission Y: Enabled N: Disabled |
| lotteryEnabled | String | Lottery permission Y: Enabled N: Disabled |
| role | String | Role Assistant: Teaching Assistant Guest: Guest |
| chatListEnabled | String | Online list display toggle on assistant page Y: Enabled N: Disabled |
| chatAuditEnabled | String | Assistant chat audit permission Y: Enabled N: Disabled |
| monitorEnabled | String | Monitoring permission toggle Y: Enabled N: Disabled |
| roundTourEnabled | String | Assistant round-robin patrol permission toggle Y: Enabled N: Disabled |
| watchLockEnabled | String | Lock live room permission Y: Enabled N: Disabled |
| loginUrl | String | Sub-account (guest) login URL |
Java Request Example
For quick integration, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. The test case files HttpUtil.java and LiveSignUtil.java are included in the download package.
It is strongly recommended to use the Live Java SDK for API 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 testBatchCreate() 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/account/batch-create";
String channelId="2191569";
//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));
String json = "[{\"role\":\"Guest\",\"nickname\":\"嘉宾\",\"passwd\":123456},{\"role\":\"Assistant\",\"nickname\":\"助教\",\"passwd\":123456}]";
url = HttpUtil.appendUrl(url,requestMap);
String response= HttpUtil.postJsonBody(url,json,null);
log.info("测试批量创建角色,返回值:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"",
"data":[
{
"account":"0052191569",
"userId":"1b448be323",
"channelId":2191569,
"passwd":"******",
"nickname":"嘉宾",
"stream":"kmd6qbz0",
"status":"Y",
"createdTime":1615969860000,
"lastModified":1615969860000,
"channelSessionId":null,
"sort":5,
"avatar":"//s1.videocc.net/default-img/avatar/guest.png",
"actor":"嘉宾",
"pageTurnEnabled":"N",
"notifyEnabled":"N",
"checkinEnabled":"Y",
"voteEnabled":"N",
"lotteryEnabled":"N",
"role":"Guest",
"chatListEnabled":"Y",
"chatAuditEnabled":"N",
"monitorEnabled":"N",
"roundTourEnabled":"N",
"watchLockEnabled":"N",
"loginUrl":null
},
{
"account":"0062191569",
"userId":"1b448be323",
"channelId":2191569,
"passwd":"******",
"nickname":"助教",
"stream":"kmd6qbz3",
"status":"Y",
"createdTime":1615969860000,
"lastModified":1615969860000,
"channelSessionId":null,
"sort":6,
"avatar":"//s1.videocc.net/default-img/avatar/assistant.png",
"actor":"助教",
"pageTurnEnabled":"N",
"notifyEnabled":"Y",
"checkinEnabled":"Y",
"voteEnabled":"Y",
"lotteryEnabled":"Y",
"role":"Assistant",
"chatListEnabled":"Y",
"chatAuditEnabled":"N",
"monitorEnabled":"N",
"roundTourEnabled":"N",
"watchLockEnabled":"N",
"loginUrl":null
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
