保利威文档中心

帮助中心

批量切换频道到达内直播CDN接口

更新时间:2022-09-02 18:08:07

接口URL

http://api.polyv.net/live/v3/channel/stream/switch-tedu-cdn

接口说明

1.根据频道号切换直播cdn域名(支持一次查询多个频道号,用逗号隔开)
2.接口支持https

请求方式

POST

请求参数

参数名 必选 类型及范围 说明
sign true String 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则
appId true string 开发者账号下的appId
timestamp true string 13位当前时间的时间戳
channelIds true string 频道号。多个用英文逗号隔开

返回错误结果JSON示例

签名错误:
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
时间戳错误:
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
appId错误
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
应用找不到
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
频道号错误
{
    "code": 400,
    "status": "error",
    "message": "channelIds is required.",
    "data": ""
}

返回正确结果JSON示例

{
    "code":200,
    "status":"success",
    "message":"",
    "data":"success"
}

字段说明

字段 类型及范围 说明
code int 接口请求状态码,200表示成功
status string 接口请求状态,"success"表示成功
message string 请求失败时返回的错误信息
data string success表示成功

PHP请求示例

<?php

//引用config.php
include 'config.php';

$streams = "13999,293333";
$params = array(
        'appId'=>$appId,
        'channelIds'=>$channelIds,
        'timestamp'=>$timestamp
    );

//生成sign
$sign = getSign($params); //详细查看config.php文件
$params['sign'] = $sign;

$url="http://api.polyv.net/live/v3/channel/stream/switch-tedu-cdn".http_build_query($params);

$ch = curl_init() or die ( curl_error() );
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 360);
$response = curl_exec ( $ch );
curl_close ( $ch );
echo $response;
?>
联系客服,在线咨询