保利威文档中心

幫助中心

建立系列直播場次

更新時間:2026-07-27 15:03:24

介面說明

1、创建系列直播场次
2、接口支持https协议

介面URL

http://api.polyv.net/live/v4/channel/session/new/create

線上API呼叫

請求方式

POST

介面限制

1、介面同時支援HTTP、HTTPS,建議使用HTTPS確保介面安全,介面呼叫有頻率限制,詳細請查看

請求參數說明

參數名 必選 類型 說明
appId true String 帳號appId【詳見取得金鑰
timestamp true Long 目前13位毫秒級時間戳,3分鐘內有效
sign true String 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則
channelId true Integer 頻道號

請求體參數說明

參數名 必選 類型 說明
name true String 場次名稱
planStartTime true String 場次開始時間 (13位時間戳)
planEndTime true Long 場次結束時間 (13位時間戳)
interactionScriptId false Integer 互動腳本ID
playType false String 播放方式(normal普通播放、loop循環播放)
splashImg false String 場次封面圖
splashLargeImg false String 直式引導大圖
splashImgBackgroundId false String 場次封面背景圖ID
streamType false String 流類型(普通直播:client/偽直播:realDiskVideo)
videoPoolId false String 偽直播對應素材庫影片ID(streamType為realDiskVideo時必傳)

範例

http://api.polyv.net/live/v4/channel/session/new/create?appId=frlr1zazn3&timestamp=1632809855078&channelId=2588188&sign=D02FA683640135D843D485EE84F6632A

請求體json參數:

{
  "name": "专题直播-新品发布会",
  "planStartTime": 1761201943000,
  "planEndTime": 1761201953000,
  "interactionScriptId": 123,
  "playType": "normal",
  "splashImg": "https://example.com/splash.jpg",
  "splashLargeImg": "https://example.com/splash-large.jpg",
  "splashImgBackgroundId": "1",
  "streamType": "client",
  "videoPoolId": "vid_abc123"
}

回應參數說明

參數名 類型 說明
code Integer 狀態碼,與http狀態碼相同,用於確定基本的回應狀態
status String 回應結果,由業務決定,成功回傳success,失敗回傳error
success Boolean 是否成功回應
requestId String 請求ID,每次請求產生的唯一UUID,僅可用於排查、除錯,不應該和業務掛鉤
data Object 場次回應物件【詳見data欄位說明
error Object 錯誤資訊

data欄位說明

參數名 類型 說明
channelId Integer 頻道ID
userId String POLYV使用者ID
sessionId String 場次ID
name String 場次名稱
endTime Long 場次結束時間
createdTime Long 場次開始時間
planStartTime Long 計劃開始時間
planEndTime Long 計劃結束時間
splashImg String 封面圖
splashLargeImg String 直式、大圖模式的封面圖
splashImgBackgroundId Integer 封面圖的背景模板id
pushClient String 推流用戶端類型
type String 場次類型(manual:手動建立場次,auto:自動建立場次)

Java請求範例

快速接入基礎代碼請下載相關依賴原始碼點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。

強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。

private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
 * 创建新版场次
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void testSessionNewCreateV4() 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/session/new/create";

    Map<String, String> query = new HashMap<>();
    query.put("appId", appId);
    query.put("timestamp", timestamp);
    query.put("channelId", "2588188");
    query.put("sign", LiveSignUtil.getSign(query, appSecret));

    Map<String, Object> body = new HashMap<>();
    body.put("name", "专题直播-新品发布会");
    body.put("planStartTime", "1761201943000");
    body.put("planEndTime", "1761201953000");
    body.put("interactionScriptId", 123);
    body.put("playType", "normal");
    body.put("videoPoolId", "vid_abc123");

    String fullUrl = HttpUtil.appendUrl(url, query);
    String response = HttpUtil.postJsonBody(fullUrl, JSON.toJSONString(body), null);
    log.info("返回值:{}", response);
}

回應範例

系統全域錯誤說明詳見全域錯誤說明

成功範例

{
  "code": 200,
  "status": "success",
  "requestId": "847f0716fa76461baf8979aaa4415dc3.67.16342672396023837",
  "data": {
    "channelId": 2588188,
    "userId": "1b448be323",
    "sessionId": "e9s2h3jd8f",
    "name": "专题直播-新品发布会",
    "startTime": 1761201943000,
    "endTime": null,
    "createdTime": 1761201943000,
    "planStartTime": 1761201943000,
    "planEndTime": 1761201953000,
    "splashImg": "https://example.com/splash.jpg",
    "splashLargeImg": "https://example.com/splash-large.jpg",
    "splashImgBackgroundId": 1,
    "pushClient": "client"
  },
  "success": true
}

異常範例

{
  "code": 400,
  "status": "error",
  "requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
  "error": {
    "code": 20001,
    "desc": "application not found."
  },
  "success": false
}
联系客服,在线咨询