添加频道商品
接口描述
1、添加频道商品库商品
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
接口URL
http://api.polyv.net/live/v3/channel/product/add
请求方式
POST
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
2、当商品类型为普通商品时,商品名称、商品封面链接、商品实际价格、商品上下架状态、商品链接类型必传,并根据商品链接类型传入对应链接;当商品类型为金融商品时,商品名称、商品上下架状态、商品链接类型必传,并根据商品链接类型传入对应链接
请求参数描述
请求体参数描述
productType
false
String
商品类型,默认为普通商品 normal:普通商品 finance:金融商品 position:职位商品
cover
false
String
普通商品(productType为normal)时,商品封面链接,必传且长度范围:1-500 金融商品(productType为finance)时,产品封面,非必填 职位商品(productType为position)时,职位封面,非必填
name
true
String
普通商品(productType为normal)时,商品名称,必填 金融商品(productType为finance)时,产品名称,必填 职位商品(productType为position)时,职位名称,必填 注:接口可支持1-100字符,直播后台设置仅支持1-50个字符
status
true
Integer
商品上下架状态 1:上架状态 2:下架状态
linkType
true
Integer
商品链接类型 10:通用链接 11:多平台链接
link
false
String
通用链接,商品链接,链接地址长度为1-500 当请求参数linkType=10时,该参数必填 当请求参数linkType=11时,该参数为非必填
pcLink
false
String
多平台链接,pc端跳转链接,链接地址长度为1-500
mobileLink
false
String
多平台链接,移动web端链接
wxMiniprogramLink
false
String
多平台链接,小程序内页面路径及参数(对于path属性,所声明的页面路径必须添加.html后缀,如pages/home/index.html)
wxMiniprogramOriginalId
false
String
多平台链接,小程序端原始Id
mobileAppLink
false
String
多平台链接,移动App端链接
androidLink
false
String
多平台链接,移动APP-安卓系统原生页面链接
iosLink
false
String
多平台链接,移动APP-苹果系统原生页面链接
params
false
String
自定义参数,该参数以String类型的json对象接收,请求时需要转义,见下方请求体参数示例
普通商品(productType为normal)时示例:{"id":21,"color":"blue","level":1}
,非必填
金融商品(productType为finance)时示例:{"id":21,"color":"blue","level":1}
,非必填
职位商品(productType为position)时必填且必须上传treatment(薪资/待遇)参数,例如:{"treatment":"7~8k"}
productDesc
false
String
普通商品(productType为normal)时,商品描述,非必填 金融商品(productType为finance)时,产品描述,非必填 职位商品(productType为position)时,职位描述,必填
features
false
String
该参数以String类型的json对象接收,请求时需要转义,见下方请求体参数示例
普通商品(productType为normal)时,产品标签,json数组,例如:["tab1", "tab2"]
金融商品(productType为finance)时,产品标签,json数组,例如:["tab1", "tab2"]
职位商品(productType为position)时,职位标签,json数组,例如:["tab1", "tab2", "tab3"]
,职位商品标签不足三个时用空字符串代替
realPrice
false
Float
普通商品(productType为normal)参数,商品实际价格,商品类型为普通商品时必传,保留两位小数,如:0.01
price
false
Float
普通商品(productType为normal)参数,商品原价,保留两位小数,如:0.01
btnShow
true
String
按钮显示文案
yield
false
String
金融商品(productType为finance)参数,产品收益率/价格
originId
false
String
平台商品id,(有值则平台商品库复制新建频道商品,此时其他字段只有status为必填)
### 示例
http://api.polyv.net/live/v3/channel/product/add?appId=frlr1zazn3&sign=8C89A574637594B0CB524039FC6D66C9&channelId=2288633×tamp=1622177434141
请求体参数
{
"name": "测试添加金融产品1",
"status": "1",
"linkType": 10,
"link": "http://live.polyv.net",
"btnShow": "测试按钮显示",
"productDesc": "测试产品描述",
"yield": "10.01%",
"features": "[\"tab1\", \"tab2\"]",
"params": "{\"id\":21,\"color\":\"blue\",\"level\":1}",
"productType": "finance"
}
响应参数描述
productId
Integer
商品productId
userId
String
POLYV用户ID,和保利威官网一致,获取路径:官网->登录->直播(开发设置)
channelId
String
频道号
name
String
商品名称
price
Float
商品价格,保留两位小数,如:0.01
cover
String
商品封面链接
link
String
商品通用类型商品链接
status
Integer
商品上下架状态 , 1:上架状态 2:下架状态
createdTime
Long
创建商品时间,13位毫秒级时间戳
lastModified
Long
更新商品时间,13位毫秒级时间戳
rank
Integer
商品排序号
realPrice
Float
商品实际价格,保留两位小数,如:0.01
type
String
平台标志,默认live,其他无效
linkType
Integer
商品链接类型, 10:通用链接 11:多平台链接
pcLink
String
多平台链接,PC端跳转链接
mobileLink
String
多平台链接,移动WEB端跳转链接
wxMiniprogramLink
String
多平台链接,小程序端跳转链接
wxMiniprogramOriginalId
String
多平台链接,小程序端ID
mobileAppLink
String
多平台链接,移动APP端跳转链接
androidLink
String
多平台链接,移动APP-安卓系统原生页面链接
iosLink
String
多平台链接,移动APP-苹果系统原生页面链接
params
String
自定义参数,json对象
productType
String
商品类型 normal:普通商品 finance:金融商品 position:职位商品
btnShow
String
按钮显示文案
features
String
普通商品(productType为normal)时,产品标签,json数组,例如:["tab1", "tab2"]
金融商品(productType为finance)时,产品标签,json数组,例如:["tab1", "tab2"]
职位商品(productType为position)时,职位标签,json数组,例如:["tab1", "tab2"]
productDesc
String
产品描述,支持特殊字符
yield
String
产品收益率/价格
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 添加商品
* @throws IOException
*/
@Test
public void testAddChannelProduct() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "2288633";
String url = "http://api.polyv.net/live/v3/channel/product/add";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
url=HttpUtil.appendUrl(url,requestMap);
String json = "{\"name\":\"测试添加金融产品1\",\"status\":\"1\",\"linkType\":10,\"link\":\"http://live.polyv.net\",\"btnShow\":\"测试按钮显示\",\"productDesc\":\"测试产品描述\",\"yield\":\"10.01%\",\"features\":\"[\\\"tab1\\\", \\\"tab2\\\"]\",\"productType\":\"finance\"}";
String response = HttpUtil.postJsonBody(url, json,null);
log.info("测试添加商品:{}",response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code": 200,
"status": "success",
"message": "",
"data": {
"productId": 134827,
"userId": "1b448be323",
"channelId": 2272655,
"name": "测试添加金融产品1",
"price": null,
"cover": "",
"link": "http://live.polyv.net",
"status": 1,
"createdTime": 1661390909000,
"lastModified": 1661390909000,
"rank": 55,
"realPrice": 0,
"type": "live",
"linkType": 10,
"pcLink": "",
"mobileLink": "",
"androidLink": null,
"iosLink": null,
"otherLink": null,
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": "",
"mobileAppLink": "",
"params": "{\"id\": 21, \"color\": \"blue\", \"level\": 1}",
"productType": "finance",
"btnShow": "测试按钮显示",
"features": "[\"tab1\", \"tab2\"]",
"productDesc": "测试产品描述",
"yield": "10.01%"
}
}
异常示例
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Last updated
Was this helpful?