创建用户身份信息
接口描述
1、创建用户身份信息
2、接口支持https协议
接口URL
https://api.polyv.net/live/v4/user/viewer-record/create
请求方式
POST
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
请求体参数描述
nickname
true
String
观众昵称,最大长度64个字符
mobile
false
String
手机号码,最大长度20个字符
name
false
String
收集姓名
lastCollectMobile
false
String
最后收集手机号码
false
String
邮箱
area
false
String
地址
latestAccessIp
false
String
最后访问IP
device
false
String
设备信息
示例
https://api.polyv.net/live/v4/user/viewer-record/create?appId=frlr1zazn3&sign=012332FBD8DBCFC068AFCB484A2ADECB×tamp=1670550787318
请求体json参数:
{
"mobile": "demoData",
"nickname": "demoData",
"name": "demoData",
"lastCollectMobile": "demoData",
"email": "demoData",
"area": "demoData",
"latestAccessIp": "demoData",
"device": "demoData"
}
响应体json:
{
"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参数描述
viewerUnionId
true
String
观众id
nickname
true
String
观众昵称
mobile
false
String
手机号码
source
true
String
用户来源
name
true
String
采集姓名
lastCollectMobile
false
String
采集手机号码
true
String
邮箱
area
true
String
地址
latestAccessIp
true
String
最后访问IP
device
true
String
设备信息
watchDuration
true
Integer
观看时长
watchChannelCount
true
Integer
观看频道数
latestAuthTime
true
timestamp
最后授权时间
createTime
true
timestamp
创建时间
Error参数描述
code
Integer
错误代码,用于确定具体的错误原因
desc
String
错误描述,与 error.code 对应
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
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
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"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
}
异常示例
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
Last updated
Was this helpful?