Batch Create Robot Virtual Nicknames
API Description
1、批量创建机器人虚拟昵称
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
API URL
http://api.polyv.net/live/v4/global/robot/save-batch
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The number of robot profiles created at once cannot exceed 200
Duplicate nicknames are allowed
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details on obtaining keys |
| 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 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 for response data. See signature generation rules |
| timestamp | true | String | Current 13-digit millisecond timestamp, valid for 3 minutes |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Virtual nickname, required, emoji not supported, no more than 20 characters |
| avatar | false | String | Robot avatar. If not provided or empty, the default avatar will be set |
Example
http://api.polyv.net/live/v4/global/robot/save-batch?appId=frlr1zazn3&sign=FAA7C22E73FA521B4CA48BB543252059×tamp=1679023736161
Request body parameters:
[
{
"name": "虚拟昵称1",
"avatar": "https://liveimages.videocc.net/uploaded/images/2023/03/gj5fk2a06r.png"
},
{
"name": "虚拟昵称2"
}
]
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| data | Object | Data for successful response |
| error | Object | Error information when status code is not 200 See Error parameter description |
| requestId | String | Request ID, a unique UUID generated for each request, used only for debugging and troubleshooting, not related to business logic |
| status | String | Response result, determined by business logic. Returns success on success, error on failure |
| success | Boolean | Whether the response was successful |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to identify the specific error reason |
| desc | String | Error description, corresponding to error.code |
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 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 unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 批量创建机器人虚拟昵称
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void robotSaveBatchTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/global/robot/save-batch";
//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);
List<Object> jsonList = new ArrayList<>();
Map<String, String> jsonMap = new HashMap<>();
jsonMap.put("name","虚拟昵称1");
jsonMap.put("avatar","https://liveimages.videocc.net/uploaded/images/2023/03/gj5fk2a06r.png");
jsonList.add(jsonMap);
jsonMap = new HashMap<>();
jsonMap.put("name","虚拟昵称2");
jsonList.add(jsonMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonList),null);
log.info("测试批量创建机器人虚拟昵称成功:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "99d7e672d04d42698d9c95fb70e7c9ab.66.16790237605309137",
"data": null,
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
