创建频道卡片推送
接口描述
1、创建频道卡片推送,对应新版后台的 营销-卡片
2、接口支持https协议
接口URL
http://api.polyv.net/live/v4/channel/card-push/create
请求方式
GET
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
timestamp
true
Long
当前13位毫秒级时间戳,3分钟内有效
sign
true
String
签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据
【详见签名生成规则】
channelId
true
String
频道号
imageType
true
String
卡片样式类型 giftbox:礼物领取样式 redpack:红包样式 custom:自定义
title
true
String
卡片标题,最多16个字符
link
true
String
卡片跳转链接地址,需要带http:等协议头
duration
true
Integer
卡片倒计时时长,取值:0,5,10,20,30,单位:秒,0为不显示倒计时时长
showCondition
true
String
弹出方式 PUSH:推送后立即弹出 WATCH:观看后弹出
conditionValue
false
Integer
观看后弹出的观看时长,showCondition为WATCH时生效
conditionUnit
false
String
观看后弹出的观看时长单位,showCondition为WATCH时,该值生效且必填 SECONDS:秒 MINUTES:分钟
countdownMsg
false
String
倒计时文案,showCondition为WATCH时生效,最多8个字符
enterEnabled
true
String
卡片入口开关 Y:开启 N:关闭
linkEnabled
false
String
卡片跳转开关 Y:开启 N:关闭
redirectType
false
String
跳转方式 iframe:页内显示 tab:新开页面
enterImage
false
String
卡片入口图片
cardImage
false
String
卡片图片
示例
http://api.polyv.net/live/v4/channel/card-push/create?duration=10&showCondition=PUSH&countdownMsg=%E6%B5%8B%E8%AF%958%E4%B8%AA%E5%AD%97%E7%AC%A6%E6%88%90%E5%8A%9F&appId=frlr1zazn3&link=http%3A%2F%2Fwww.polyv.net&sign=7C51748CDDE6CE707031B3B9F75F8E0D&conditionValue=20&enterEnabled=Y&title=%E5%8D%A1%E7%89%87%E6%8E%A8%E9%80%81&imageType=redpack&channelId=2523307×tamp=1632882516916
响应参数描述
Error参数描述
code
Integer
错误代码,用于确定具体的错误原因
desc
String
错误描述,与 error.code 对应
Data参数描述
id
Long
卡片推送ID
channelId
Integer
频道ID
title
String
卡片标题,最多16个字符
imageType
String
卡片样式类型 giftbox:礼物领取样式 redpack:红包样式 custom:自定义
duration
Integer
卡片倒计时时长,取值:0,5,10,20,30,单位:秒,0为不显示倒计时时长
link
String
卡片跳转链接地址,带http://等协议头
pushEndTime
Long
推送结束时间,13位时间戳
createdTime
Long
创建时间,13位时间戳
lastModified
Long
修改时间,13位时间戳
pushStatus
String
推送状态 Y:推送中 N:未推送 L:上次推送
pushTime
Long
推送时间,13位时间戳
enterEnabled
String
卡片入口 Y:开启 N:关闭
showCondition
String
弹出方式 PUSH:推送后立即弹出 WATCH:观看后弹出
conditionValue
Integer
观看时长
conditionUnit
String
观看时长单位 SECONDS:秒 MINUTES:分钟
countdownMsg
String
倒计时文案,showCondition为WATCH时生效,最多8个字符
linkEnabled
String
卡片跳转开关 Y:开启 N:关闭
redirectType
String
跳转方式 iframe:页内显示 tab:新开页面
enterImage
String
卡片入口图片
cardImage
String
卡片图片
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
/**
* 测试创建频道卡片推送
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testCreateChannelCardPush() 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/channel/card-push/create";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", "2523307");
requestMap.put("imageType", "redpack");
requestMap.put("title", "卡片推送");
requestMap.put("link", "http://www.polyv.net");
requestMap.put("duration", "10");
requestMap.put("showCondition", "PUSH");
requestMap.put("conditionValue", "20");
requestMap.put("countdownMsg", "测试8个字符成功");
requestMap.put("enterEnabled", "Y");
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url,requestMap);
log.info("测试创建频道卡片推送成功,返回值:{}", response);
}
响应示例
成功示例
{
"code": 200,
"status": "success",
"requestId": "3118812d-f657-409b-b149-631f6799f7d1",
"data": {
"id": 1187,
"channelId": 2523307,
"title": "卡片推送",
"imageType": "redpack",
"duration": 10,
"link": "http://www.polyv.net",
"pushEndTime": 1632882522413,
"createdTime": 1632882522416,
"lastModified": null,
"pushStatus": "N",
"pushTime": null,
"enterEnabled": "Y",
"showCondition": "PUSH",
"conditionValue": 20,
"conditionUnit": null,
"countdownMsg": "测试8个字符成功"
},
"success": true
}
异常示例
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.117.16360829892566053",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
Last updated
Was this helpful?