group_create_viewer_name
Updated: 2025-09-26 17:36:06
Description
1、分组添加观众支持传昵称
2、接口支持https协议
Interface URL
http://api.polyv.net/live/v4/channel/lottery-viewer-list/create-viewer-name
Request Method
POST
Call Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended for security. The interface has call frequency limits. For details, please refer to bzd.
If parameters are incorrect, a 400 exception will be returned.
Request Parameter Description
Request Body Parameter Description
viewerNames Parameter Description
Request Body JSON Parameters:
{
"groupId": 1900,
"viewerNames": [
{
"viewerId": "19",
"viewerName": "中文"
},
{
"viewerId": "190",
"viewerName": "English"
},
{
"viewerId": "1900",
"viewerName": ""
}
]
}
Example
https://api.polyv.net/live/v4/channel/lottery-viewer-list/create-viewer-name?appId=hb5u8hrdz9&channelId=6560451×tamp=1758087275475&sign=7C409278FE170B563A3802D56734C61E
Response Parameter Description
Error Response Description
data Response Description
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 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 for API functionality integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private final Logger log = LoggerFactory.getLogger(getClass());
/**
* 分组批量添加观众昵称(create-viewer-name)
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void groupViewerNamesAdd() throws IOException, NoSuchAlgorithmException {
// 公共参数(请替换为你的实际值)
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
// API 地址(使用 HTTPS)
String url = "https://api.polyv.net/live/v4/channel/lottery-viewer-list/create-viewer-name";
// 业务参数
int channelId = 5004544; // 频道号
int groupId = 1900; // 分组ID
// 待添加的观众
List<Map<String, String>> viewerNames = new ArrayList<>();
viewerNames.add(Map.of("viewerId", "19", "viewerName", "中文"));
viewerNames.add(Map.of("viewerId", "190", "viewerName", "English"));
viewerNames.add(Map.of("viewerId", "1900", "viewerName", "")); // 允许空昵称
// http 调用逻辑
Map<String, String> query = new HashMap<>();
query.put("appId", appId);
query.put("timestamp", timestamp);
query.put("channelId", String.valueOf(channelId)); // 注意:Map<String,String> 需转字符串
// 组装 JSON Body
Map<String, Object> body = new HashMap<>();
body.put("groupId", groupId);
body.put("viewerNames", viewerNames);
// 生成签名(大写 32 位 MD5)。通常仅包含公共参数;若签名包含 body 字段,请与服务端保持一致。
query.put("sign", LiveSignUtil.getSign(query, appSecret));
// 拼接带 query 的最终URL
url = HttpUtil.appendUrl(url, query);
// 发送 JSON(确保 Content-Type: application/json; charset=utf-8)
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(body), null);
log.info("测试分组批量添加观众昵称,返回值:{}", response);
// do something...
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "32d9c92e-99b4-4941-ab0b-661291d57115",
"data": [
{
"id": 653349,
"groupId": 1900,
"viewerId": "19",
"viewerName": "中文",
"createTime": 1758268299975
},
{
"id": 653350,
"groupId": 1900,
"viewerId": "190",
"viewerName": "English",
"createTime": 1758268299975
},
{
"id": 653351,
"groupId": 1900,
"viewerId": "1900",
"viewerName": "",
"createTime": 1758268299975
}
],
"success": true
}
Error Example
{
"code": 20000,
"status": "error",
"error": {
"code": 20000,
"desc": "appId is required."
},
"success": false
}