创建频道卡片推送
更新时间:2025-11-03 18:26:29
接口描述
1、创建频道卡片推送,对应新版后台的 营销-卡片
2、接口支持https协议
接口URL
http://api.polyv.net/live/v4/channel/card-push/create
请求方式
GET
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| appId | true | String | 账号appId【详见获取密钥】 |
| timestamp | true | Long | 当前13位毫秒级时间戳,3分钟内有效 |
| sign | true | String | 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则】 |
| channelId | true | String | 频道号 |
| cardType | false | String | 卡片类型,common-普通卡片,qrCode-二维码,默认:common |
| imageType | true | String | 卡片样式类型 giftbox:礼物领取样式 redpack:红包样式 custom:自定义 weixinWork:企微 |
| title | true | String | 卡片标题,最多16个字符 |
| link | true | String | 卡片跳转链接地址,需要带http:等协议头(当 hrefType=common 时使用) |
| duration | true | Integer | 卡片倒计时时长,取值:0,5,10,20,30,单位:秒,0为不显示倒计时时长 |
| durationPosition | false | String | 卡片倒计时时长显示位置,bottom-底部,top-右上角 |
| showCondition | true | String | 弹出方式 PUSH:推送后立即弹出 WATCH:观看后弹出 |
| conditionValue | false | Integer | 观看后弹出的观看时长,showCondition为WATCH时生效 |
| conditionUnit | false | String | 观看后弹出的观看时长单位,showCondition为WATCH时,该值生效且必填 SECONDS:秒 MINUTES:分钟 |
| countdownMsg | false | String | 倒计时文案,showCondition为WATCH时生效,最多8个字符 |
| enterEnabled | false | String | 卡片入口开关 Y:开启 N:关闭 |
| linkEnabled | false | String | 卡片跳转开关 Y:开启 N:关闭 |
| redirectType | false | String | 跳转方式 iframe:页内显示 tab:新开页面 |
| enterImage | false | String | 卡片入口图片 |
| cardImage | false | String | 卡片图片 |
| weixinWordQrCodeId | false | String | 企微渠道码ID(当 imageType=weixinWork 时生效) |
| qrCodeImage | false | String | 二维码图片(当 cardType=qrCode 时生效) |
| hrefType | false | String | 跳转类型,common-普通(使用 link 字段),multiplatform-多平台(使用多端链接字段) |
| 以下参数,当 hrefType=multiplatform 时生效 | |||
| pcLink | false | String | 电脑浏览器链接 |
| mobileLink | false | String | 手机浏览器链接 |
| wxMiniprogramOriginalId | false | String | 微信小程序原始ID |
| wxMiniprogramAppId | false | String | 微信小程序appId |
| wxMiniprogramLink | false | String | 微信小程序页面路径 |
| mobileAppLink | false | String | 手机App链接 |
示例
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
响应参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 响应状态码,200为成功返回,非200为失败 |
| status | String | 响应结果,由业务决定,成功返回success,失败返回error |
| success | Boolean | 响应结果,由业务决定,成功返回true,失败返回false |
| data | Object | 成功响应时返回创建成功的卡片信息【详见Data字段说明】 |
| error | Object | 状态码非200时的错误信息【详见Error字段说明】 |
| requestId | String | 请求ID,每次请求生成的唯一的 UUID,仅可用于排查、调试,不应该和业务挂上钩 |
Error参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 错误代码,用于确定具体的错误原因 |
| desc | String | 错误描述,与 error.code 对应 |
Data参数描述
| 参数名 | 类型 | 说明 |
|---|---|---|
| id | Long | 卡片推送ID |
| channelId | Integer | 频道ID |
| title | String | 卡片标题,最多16个字符 |
| cardType | String | 卡片类型,common-普通卡片,qrCode-二维码 |
| imageType | String | 卡片样式类型 giftbox:礼物领取样式 redpack:红包样式 custom:自定义 |
| duration | Integer | 卡片倒计时时长,取值:0,5,10,20,30,单位:秒,0为不显示倒计时时长 |
| durationPosition | String | 卡片倒计时时长显示位置,bottom-底部,top-右上角 |
| 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:秒 MINUTE:分钟 |
| countdownMsg | String | 倒计时文案,showCondition为WATCH时生效,最多8个字符 |
| linkEnabled | String | 卡片跳转开关 Y:开启 N:关闭 |
| redirectType | String | 跳转方式 iframe:页内显示 tab:新开页面 |
| enterImage | String | 卡片入口图片 |
| cardImage | String | 卡片图片 |
| weixinWordQrCodeId | String | 企微渠道码ID |
| weixinwordQrCodeName | String | 企微渠道码名称 |
| qrCodeImage | String | 二维码图片 |
| hrefType | String | 跳转类型,common-普通,multiplatform-多平台 |
| pcLink | String | 电脑浏览器链接 |
| mobileLink | String | 手机浏览器链接 |
| wxMiniprogramOriginalId | String | 微信小程序原始ID |
| wxMiniprogramAppId | String | 微信小程序appId |
| wxMiniprogramLink | String | 微信小程序页面路径 |
| mobileAppLink | String | 手机App链接 |
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个字符成功",
"linkEnabled": "Y",
"cardType": "common",
"hrefType": "common",
"pcLink": null,
"mobileLink": null,
"wxMiniprogramOriginalId": "xxx",
"wxMiniprogramAppId": "xxx",
"wxMiniprogramLink": "xxx",
"durationPosition": null,
"mobileAppLink": null
},
"success": true
}
异常示例
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.117.16360829892566053",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
