Copy 1、批量创建机器人虚拟昵称
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Copy http://api.polyv.net/live/v4/global/robot/save-batch
Copy http://api.polyv.net/live/v4/global/robot/save-batch?appId=frlr1zazn3&sign=FAA7C22E73FA521B4CA48BB543252059×tamp=1679023736161
Copy [
{
"name": "虚拟昵称1",
"avatar": "https://liveimages.videocc.net/uploaded/images/2023/03/gj5fk2a06r.png"
},
{
"name": "虚拟昵称2"
}
]
强烈建议您使用直播Java SDK 完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
Copy 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
}
Copy {
"code" : 200 ,
"status" : "success" ,
"requestId" : "99d7e672d04d42698d9c95fb70e7c9ab.66.16790237605309137" ,
"data" : null ,
"success" : true
}
Copy {
"code" : 400 ,
"status" : "error" ,
"requestId" : "d310b70bc329403f87f77f9203d50f89.128.16360831552223589" ,
"error" : {
"code" : 20001 ,
"desc" : "application not found."
} ,
"success" : false
}