点击这里查看旧版
接口URL
https://api.polyv.net/live/v2/channelRestrict/{channelId}/set-max-viewer
接口说明
1、设置频道最大观看在线人数
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID
支持格式
JSON
请求方式
POST
请求数限制
TRUE
请求参数
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
appId | 是 | string | 从API设置中获取,在直播系统登记的appId |
timestamp | 是 | string | 当前13位毫秒级(兼容10位秒级)时间戳,3分钟内有效 |
userId | 是 | string | 直播账号ID |
maxViewer | 是 | int | 最大观看在线人数,等于0时表示关闭在线人数观看限制 |
sign | 是 | string | 签名,为32位的大写MD5值 |
响应成功JSON示例:
{
"code": 200,
"status": "success",
"message": "",
"data": "设置成功"
}
响应失败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": ""
}
用户ID为空
{
"code": 400,
"status": "error",
"message": "userId is blank.",
"data": ""
}
最大在线人数错误
{
"code": 400,
"status": "error",
"message": "maxViewer is less than or equal to 0.",
"data": ""
}
设置失败
{
"code": 400,
"status": "error",
"message": "设置失败",
"data": ""
}
字段说明
参数名 | 说明 |
---|---|
code | 请求状态响应码 |
status | 请求状态 |
message | 错误信息 |
data | 请求结果 |
php请求示例
<?php
//引用config.php
include 'config.php';
$channelId = "XXXXX";
//接口需要的参数(非sign)赋值
$userId = "XXXXXXXX";
$channelId = "127075";
$maxViewer = 100;
$params = array(
'appId'=>$appId,
'userId'=>$userId,
'maxViewer'=>$maxViewer,
'timestamp'=>$timestamp
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url="http://api.polyv.net/live/v2/channelRestrict/$channelId/set-max-viewer?appId=".$appId."×tamp=".$timestamp."&userId=".$userId."&maxViewer=".$maxViewer."&sign=".$sign;
$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;
?>