获取功能开关设置接口

接口URL

https://api.polyv.net/live/v3/channel/switch/get

接口说明

1、接口用于获取开关设置,可获取全局开关设置或频道开关设置
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传该参数为获取全局设置

响应成功JSON示例:

{
  "code": 200, 
  "status": "success", 
  "message": "", 
  "data": [
    {
      "type": "isClosePreview", 
      "enabled": "N"
    }, 
    {
      "type": "mobileWatch", 
      "enabled": "Y"
    }, 
    {
      "type": "mobileAudio", 
      "enabled": "Y"
    }, 
    {
      "type": "autoPlay", 
      "enabled": "Y"
    }, 
    {
      "type": "booking", 
      "enabled": "Y"
    }, 
    {
      "type": "redPack", 
      "enabled": "Y"
    }, 
    {
      "type": "shareBtnEnabled", 
      "enabled": "Y"
    }, 
    {
      "type": "chat", 
      "enabled": "Y"
    }, 
    {
      "type": "closeChaterList", 
      "enabled": "N"
    }, 
    {
      "type": "consultingMenu", 
      "enabled": "Y"
    }, 
    {
      "type": "closeDanmu", 
      "enabled": "N"
    }, 
    {
      "type": "praise", 
      "enabled": "Y"
    }, 
    {
      "type": "welcome", 
      "enabled": "Y"
    }, 
    {
      "type": "chatPlayBack", 
      "enabled": "Y"
    }, 
    {
      "type": "viewerSendImgEnabled", 
      "enabled": "Y"
    }
  ]
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

频道号格式错误

{
  "code": 400, 
  "status": "error", 
  "message": "param is not digit: dsadasd", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 成功响应时为当前开关设置项
type 开关类型
enabled 是否已打开开关

注:isClosePreview当enabled值为Y时,表示的是关闭系统观看页;closeDanmu当enabled值为Y时,表示的是关闭弹幕;closeChaterList当enabled值为Y时,表示的是关闭在线列表

php请求示例

<?php
//引用config.php
include '/srv/http/config.php';

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp
);

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

$url = "http://api.polyv.net/live/v3/channel/switch/get?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...