接口描述
Copy 1、创建用户身份信息
2、接口支持https协议
接口URL
Copy https://api.polyv.net/live/v4/user/viewer-record/create
请求方式
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
请求体参数描述
示例
Copy https://api.polyv.net/live/v4/user/viewer-record/create?appId=frlr1zazn3&sign=012332FBD8DBCFC068AFCB484A2ADECB×tamp=1670550787318
请求体json参数:
Copy {
"mobile" : "demoData" ,
"nickname" : "demoData" ,
"name" : "demoData" ,
"lastCollectMobile" : "demoData" ,
"email" : "demoData" ,
"area" : "demoData" ,
"latestAccessIp" : "demoData" ,
"device" : "demoData"
}
响应体json:
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
}
响应参数描述
Data参数描述
Error参数描述
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK 完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
Copy private final Logger log = LoggerFactory . getLogger ( getClass() );
/**
* 新增观众信息
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@ Test
public void createViewerTest() 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/create" ;
//业务参数
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 ( "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
}