Copy https://api.polyv.net/live/v4/user/viewer-record/update
Copy https://api.polyv.net/live/v4/user/viewer-record/update?appId=frlr1zazn3&sign=012332FBD8DBCFC068AFCB484A2ADECB×tamp=1670550787318
Copy {
"viewerUnionId" : "2_v378gn997yovtl3p8h77db9e224t6hg9" ,
"mobile" : "3333" ,
"nickname" : "2222" ,
"name" : "demoData" ,
"lastCollectMobile" : "demoData" ,
"email" : "demoData" ,
"area" : "demoData" ,
"latestAccessIp" : "demoData" ,
"device" : "demoData"
}
Copy {
"code" : 200 ,
"status" : "success" ,
"requestId" : "be18d7c8-4645-47f2-81dd-c3202d759b12" ,
"data" : true ,
"success" : true
}
强烈建议您使用直播Java SDK 完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
Copy private final Logger log = LoggerFactory . getLogger ( getClass() );
/**
* 更新观众信息
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@ Test
public void updateViewerTest() throws IOException , NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super . appId ;
String appSecret = super . appSecret ;
String timestamp = String . valueOf ( System . currentTimeMillis ());
String url = "https://api.polyv.net/live/v4/user/viewer-record/update" ;
//业务参数
String viewerUnionId = "2_v378gn997yovtl3p8h77db9e224t6hg9" ;
String mobile = "demoData" ;
String nickname = "demoData" ;
String name = "demoData" ;
String lastCollectMobile = "demoData" ;
String email = "demoData" ;
String area = "demoData" ;
String latestAccessIp = "demoData" ;
String device = "demoData" ;
//http 调用逻辑
Map < String , String > requestMap = new HashMap <>();
requestMap . put ( "appId" , appId);
requestMap . put ( "timestamp" , timestamp);
Map < String , Object > jsonMap = new HashMap <>();
jsonMap . put ( "viewerUnionId" , viewerUnionId);
jsonMap . put ( "mobile" , mobile);
jsonMap . put ( "nickname" , nickname);
jsonMap . put ( "name" , name);
jsonMap . put ( "lastCollectMobile" , lastCollectMobile);
jsonMap . put ( "email" , email);
jsonMap . put ( "area" , area);
jsonMap . put ( "latestAccessIp" , latestAccessIp);
jsonMap . put ( "device" , device);
requestMap . put ( "sign" , LiveSignUtil . getSign (requestMap , appSecret));
url = HttpUtil . appendUrl (url , requestMap);
String response = HttpUtil . postJsonBody (url , JSON . toJSONString (jsonMap) , null );
log . info ( "测试更新观众信息结果:{}" , response);
//do somethings
}
Copy {
"code" : 200 ,
"status" : "success" ,
"requestId" : "97d9bc9c-c0d2-4639-acad-54b28335004c" ,
"data" : {
"name" : "demoData" ,
"lastCollectMobile" : "demoData" ,
"email" : "demoData" ,
"area" : "demoData" ,
"latestAccessIp" : "demoData" ,
"device" : "demoData" ,
"watchDuration" : 0 ,
"watchChannelCount" : 0 ,
"viewerUnionId" : "2_2v0u6u75hw013ja684ba9co7lnppq4j9" ,
"nickname" : "demoData" ,
"mobile" : "demoData9" ,
"source" : "IMPORT" ,
"latestAuthTime" : 1712114620000 ,
"createTime" : 1712114620000
} ,
"success" : true
}
Copy {
"code" : 400 ,
"status" : "error" ,
"requestId" : "d310b70bc329403f87f77f9203d50f89.128.16360831552223589" ,
"error" : {
"code" : 20001 ,
"desc" : "application not found."
} ,
"success" : false
}