Polyv Help Center

Help Center

Create a Single Role

Updated: 2024-01-23 14:22:02

Interface Description

1、创建频道的助教或嘉宾角色
   助教:使用助教管理后台,能够观看直播、参与互动、进行聊天室管理,发送图文直播,监控直播等操作
   嘉宾:讲师和嘉宾可同时讲一堂课,支持连麦互动
2、接口URL中的{channelId}为频道号
3、接口支持https协议

Interface URL

http://api.polyv.net/live/v2/channelAccount/{channelId}/add

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

  2. Each live channel can create up to 150 teaching assistants, with a maximum of 16 guests.

  3. Creating a guest requires setting the channel's co-streaming participant count and enabling the co-streaming feature.

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 your own server to relay requests to the POLYV server for response data. [See Signature Generation Rules]
role false String Default is teaching assistant if not passed
Assistant: Teaching Assistant
Guest: Guest
nickname false String Nickname, randomly generated by default
password false String Role password
actor false String Title, defaults to teaching assistant
avatar false String Avatar, defaults to the initial avatar

Example

http://api.polyv.net/live/v2/channelAccount/2191541/add

Form Parameters:

actor=%E5%8A%A9%E6%95%99&role=Assistant&appId=frlr1zazn3&nickname=%E5%88%98%E8%80%81%E5%B8%88&sign=F9953D904B2177872672A693F53D86EB&avatar=https%3A%2F%2Fs1.videocc.net%2Fdefault-img%2Favatar%2Fassistant.png&timestamp=1621841707106

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, provides error details when code is 400 or 500
data Object Empty on failure, channel information on success [See data field description]

data Field Description

Parameter Type Description
account String Teaching assistant/guest account
userId String POLYV user ID, consistent with the Polyv official website. Path: Official Website -> Login -> Live (Development 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
Y: Enabled
N: Disabled
createdTime Long Role creation time
lastModified Long Last modification time of the role
sort Integer Channel role sequence number
avatar String Role avatar
actor String Role title
pageTurnEnabled String Whether the role has page turning permission. Only one teaching assistant can have this. Only supported in the tri-screen scenario.
Y: Yes
N: No
notifyEnabled String Whether the role has permission to publish announcements
Y: Yes
N: No
checkinEnabled String Whether the role has permission to start check-in
Y: Yes
N: No
voteEnabled String Whether the role has permission to initiate voting
Y: Yes
N: No
lotteryEnabled String Whether the role has permission to conduct lotteries
Y: Yes
N: No
role String Role
Assistant: Teaching Assistant
Guest: Guest
chatListEnabled String Toggle for displaying the online list on the teaching assistant page
Y: Enabled
N: Disabled
chatAuditEnabled String Teaching assistant chat audit
Y: Enabled
N: Disabled
monitorEnabled String Teaching assistant monitoring toggle
Y: Enabled
N: Disabled
roundTourEnabled String Teaching assistant round-robin toggle
Y: Enabled
N: Disabled
watchLockEnabled String Lock live room feature toggle
Y: Enabled
N: Disabled

Java Request Example

For quick integration of the 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 test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.

It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides a 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 testAddAccount() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "https://api.polyv.net/live/v2/channelAccount/%s/add";
    String channelId = "2149813";
    String role = "Assistant";
    String nickname = "刘老师";
    String actor = "助教";
    String avatar = "https://s1.videocc.net/default-img/avatar/assistant.png";

    url = String.format(url, channelId);
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("role", role);
    requestMap.put("nickname", nickname);
    requestMap.put("actor", actor);
    requestMap.put("avatar", avatar);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.postFormBody(url, requestMap);
    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":{
        "account":"0072149710",
        "userId":"1b448be323",
        "channelId":2149710,
        "passwd":"xxxxxx",
        "nickname":"赵老师",
        "stream":"km1fvuo3",
        "status":"Y",
        "createdTime":1615259640000,
        "lastModified":1615259640000,
        "channelSessionId":null,
        "sort":7,
        "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"
    }
}

Error Example

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