保利威文档中心

帮助中心

批量创建接收转播的频道

更新时间:2023-04-04 09:31:23

接口描述

1、根据发起转播的频道,批量创建接收转播的频道
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

接口URL

http://api.polyv.net/live/v3/channel/transmit/batch-create

请求方式

POST

接口约束

1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看

2、最大支持一次性创建100个接收转播的频道,发起转播的频道最多支持500个接收转播的频道

请求参数描述

参数名 必选 类型 说明
appId true String 账号appId【详见获取密钥
timestamp true Long 当前13位毫秒级时间戳,3分钟内有效
sign true String 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则
channelId true String 频道号(发起转播的频道号)

请求体参数描述

类型 必选 说明
Array true 接收转播的频道名称列表,例:["保利威接收转播测试频道"]

示例

http://api.polyv.net/live/v3/channel/transmit/batch-create?appId=frlr1zazn3&sign=D02FA683640135D843D485EE84F6632A&channelId=2588188&timestamp=1632809855078

请求体json参数:

[
    "接收转播频道1",
    "接收转播频道2"
]

响应参数描述

参数名 类型 说明
code Integer 响应状态码,200为成功返回,非200为失败【详见全局错误说明
status String 响应状态文本信息
message String 响应描述信息,当code为400或者500的时候,辅助描述错误原因
data Array 成功创建的接收转播的频道信息列表【详见ChannelInfo字段说明

ChannelInfo参数描述

参数名 类型 说明
channelId Integer 频道号
name String 频道名称
channelPasswd String 频道密码
authType String 频道观看条件
playBackEnabled String 频道是否开启回放,Y:开启,N:关闭
streamType String 频道推流方式
debugEnabled String 频道是否开启调试,Y:开启,N:关闭
stream String 频道流名
status String 频道状态
categoryId Integer 频道所在分类Id
categoryName String 频道所在分类名称
isSmallClass String 频道是否为小班课,Y:开启,N:关闭
newScene String 频道直播场景,和发起转播的频道一致
template String 频道直播模板,和发起转播的频道一致
createdTime Long 频道创建时间
coverImage String 频道封面图片
type String 频道类型,transmit:发起转播,normal:普通的频道,receive:接收转播
startTime Long 频道开始时间
publisher String 频道主持人
splashImg String 频道引导图图片地址
splashEnabled String 频道引导图开关,Y:开启,N:关闭
pureRtcEnabled String 频道无延迟直播开关,Y:开启,N:关闭
roomIds String 频道分房间信息,没有则返回null

Java请求示例

快速接入基础代码请下载相关依赖源码点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。

    @Test
    public void testBatchCreateTransmitChannel() 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/v3/channel/transmit/batch-create";
        String channelId = "2588188";
        
        //http 调用逻辑
        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("appId", appId);
        requestMap.put("timestamp", timestamp);
        
        requestMap.put("channelId", channelId);
        requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
        url = HttpUtil.appendUrl(url,requestMap);
        
        List<String> list = new ArrayList<>();
        list.add("接收转播频道1");
        list.add("接收转播频道2");
        
        String json= JSON.toJSONString(list);
        String response = HttpUtil.postJsonBody(url, json,null);
        log.info("测试修改频道信息,返回值:{}", response);
    }

响应示例

成功示例

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "channelId": 2588440,
            "name": "接收转播频道1",
            "channelPasswd": "8pWtmd",
            "authType": "phone",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "N",
            "stream": "1b448be3231632809860172afac",
            "status": "客户端推流/直播结束",
            "categoryId": 340019,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "newScene": null,
            "template": null,
            "createdTime": 1632809860000,
            "appId": null,
            "coverImage": "",
            "type": "receive",
            "startTime": null,
            "publisher": "主持人",
            "channelLogo": null,
            "splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null,
            "transmitType": null,
            "rtcType": null,
            "channelSessionId": null,
            "lastPushStreamTime": null
        },
        {
            "channelId": 2588441,
            "name": "接收转播频道2",
            "channelPasswd": "8pWtmd",
            "authType": "phone",
            "streamType": "client",
            "debugEnabled": "N",
            "playBackEnabled": "N",
            "stream": "1b448be323163280986017418fb",
            "status": "客户端推流/直播结束",
            "categoryId": 340019,
            "categoryName": "默认分类",
            "isSmallClass": "N",
            "scene": "ppt",
            "newScene": null,
            "template": null,
            "createdTime": 1632809860000,
            "appId": null,
            "coverImage": "",
            "type": "receive",
            "startTime": null,
            "publisher": "主持人",
            "channelLogo": null,
            "splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
            "splashEnabled": "Y",
            "pureRtcEnabled": "N",
            "watchTimes": null,
            "roomIds": null,
            "transmitType": null,
            "rtcType": null,
            "channelSessionId": null,
            "lastPushStreamTime": null
        }
    ]
}

异常示例

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