保利威文档中心

幫助中心

查詢頻道資訊

更新時間:2022-09-29 15:04:48

介面描述

1、查询直播频道信息
2、接口URL中的{channelId}为频道号
3、接口支持https协议

介面URL

http://api.polyv.net/live/v2/channels/{channelId}/get

請求方式

GET

介面限制

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

請求參數描述

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

回應參數描述

參數名 類型 說明
code Integer 回應狀態碼,200為成功返回,非200為失敗【詳見全域錯誤說明
status String 回應狀態文字資訊
message String 回應描述資訊,當code為400或500時,輔助描述錯誤原因
data Object 請求失敗時為空,請求成功時為頻道的資訊【詳見data欄位描述

data欄位描述

參數名 類型 說明
channelId String 直播頻道號
userId String 直播使用者ID
name String 直播頻道名稱
description String 直播頻道描述
url String 直播推流地址
stream String 直播流名稱
logoImage String 播放器logo
logoOpacity Float Logo不透明度,1表示完全不透明
logoPosition String Logo位置
logoHref String Logo的跳轉連結
coverImage String 播放前顯示的封面圖
coverHref String 封面圖的跳轉連結
waitImage String 等待推流時的顯示圖片
waitHref String 等待推流時顯示圖片的跳轉連結
cutoffImage String 切斷流時的顯示圖片
cutoffHref String 切斷流時顯示圖片的跳轉連結
advertType String 廣告類型
advertDuration Integer 廣告時長
advertWidth Integer 廣告區域寬度
advertHeight Integer 廣告區域高度
advertImage String 圖片廣告
advertHref String 廣告的跳轉連結
advertFlvVid String 影片廣告ID
advertFlvUrl String 影片廣告連結
playerColor String 播放器控制欄顏色
autoPlay Boolean 自動播放
warmUpFlv String 一開始的暖場影片
passwdRestrict Boolean 觀看密碼限制,需要輸入觀看密碼才能播放流
passwdEncrypted String 觀看密碼加密後的密文
isOnlyAudio String 僅推音訊流,Y:開啟,N:關閉
isLowLatency String 低延遲,Y:開啟,N:關閉
channelLogoImage String 頻道的圖示
publisher String 主持人姓名
scene String 直播場景
alone:活動直播
topclass:大班課
ppt:三分屏
seminar:研討會
channelViewerPasswd String 參與者密碼
channelPasswd String 頻道密碼
linkMicLimit Integer 頻道連麥人數
-1:使用帳號連麥人數
0-16:代表連麥人數
streamType String 直播方式
client:用戶端推流
pull:拉流
thirdpull:第三方拉流
disk:偽直播
audio:音訊直播
pureRtcEnabled String 無延遲直播開關,Y:開啟,N:關閉
type String 頻道類型
transmit:發起轉播
normal:普通的頻道
receive:接收轉播
cnAndEnLiveEnabled String 中英文直播間開關,Y:開啟,N:關閉
pushEnUrl String 英文推流地址
categoryId String 所屬分類Id
categoryName String 所屬分類名稱
currentTimeMillis Long 伺服器返回13位毫秒級時間戳

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 testGetChannelDetail() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v2/channels/%s/get";
    String channelId = "2139283";
    
    url = String.format(url, channelId);
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url, requestMap);
    log.info("测试查询频道信息,返回值:{}", response);
    //do somethings
    
}

回應範例

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

成功範例

{
    "code":200,
    "status":"success",
    "message":"",
    "data":{
        "channelId":2139283,
        "userId":"1b448be323",
        "name":"API讨论",
        "publisher":"主持人",
        "description":"",
        "url":"rtmp://push-d1.videocc.net/recordf/1b448be3231612574447801d3db?auth_key=1615187853-0-0-a389e65ee28cdbfe0388cdbba8097ca3",
        "stream":"1b448be3231612574447801d3db",
        "logoImage":"",
        "logoOpacity":1,
        "logoPosition":"tr",
        "logoHref":"",
        "coverImage":"",
        "coverHref":"",
        "waitImage":"",
        "waitHref":"",
        "cutoffImage":"",
        "cutoffHref":"",
        "advertType":"NONE",
        "advertDuration":0,
        "advertWidth":0,
        "advertHeight":0,
        "advertImage":"",
        "advertHref":"",
        "advertFlvVid":"",
        "advertFlvUrl":"",
        "playerColor":"#666666",
        "autoPlay":false,
        "warmUpFlv":"",
        "passwdRestrict":false,
        "passwdEncrypted":"",
        "isOnlyAudio":"N",
        "isLowLatency":"N",
        "m3u8Url":"http://pull-d1.videocc.net/recordf/1b448be3231612574447801d3db.m3u8?auth_key=1615186053-0-0-c9c2c9b09b982e9fe357ecf6461ef532",
        "m3u8Url1":"",
        "m3u8Url2":"",
        "m3u8Url3":"",
        "channelLogoImage":"http://liveimages.videocc.net/assets/wimages/pc_images/logo.png",
        "scene":"alone",
        "channelViewerPasswd":null,
        "channelPasswd":"xxxx",
        "linkMicLimit":16,
        "streamType":"client",
        "pureRtcEnabled":"Y",
        "type":"transmit",
        "cnAndEnLiveEnabled":"N",
        "pushEnUrl":null,
        "categoryId":340019,
        "categoryName":"默认分类",
        "currentTimeMillis":1615186053464
    }
}

異常範例

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询