保利威文档中心

幫助中心

建立頻道卡片推播

更新時間:2025-11-03 18:26:29

介面說明

1、创建频道卡片推送,对应新版后台的 营销-卡片
2、接口支持https协议

介面URL

http://api.polyv.net/live/v4/channel/card-push/create

線上API呼叫

請求方式

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-QR Code,預設: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 QR Code圖片(當 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&timestamp=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-QR Code
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 QR Code圖片
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
}
联系客服,在线咨询