文章目录
接口URL
http://api.polyv.net/live/v3/channel/auth/upload-white-list
接口说明
(接口调用有频率限制,详细请查看)
1、接口用于设置频道或全局观看条件中的白名单列表
2、接口支持https
3、如导入数据与现有列表数据会员码一致,则会以导入昵称覆盖现有昵称
返回结果支持格式
JSON
请求方式
POST
请求数限制
TRUE
请求参数
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
appId | 是 | string | 从API设置中获取,在直播系统登记的appId |
timestamp | 是 | long | 13位当前时间戳 |
sign | 是 | string | 签名值 |
channelId | 否 | int | 频道号,无该参数为全局设置 |
rank | 是 | int | 主要观看条件为1,次要观看条件为2 |
file | 是 | file | 白名单文件(白名单模板) |
响应成功JSON示例:
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
响应失败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": "param is not digit: %s",
"data": ""
}
频道不存在
{
"code": 404,
"status": "error",
"message": "channel not found.",
"data": ""
}
频道Id非法错误
{
"code": 400,
"status": "error",
"message": "illegal channel id: %s",
"data": ""
}
白名单表格记录解析错误
{
"code": 400,
"status": "error",
"message": "whitelist excel parse error.",
"data": ""
}
表格记录没有数据
{
"code": 400,
"status": "error",
"message": "whitelist excel no data.",
"data": ""
}
字段说明
参数名 | 说明 |
---|---|
code | 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500 |
status | 成功为success,错误时为error |
message | 成功为"",错误时为错误描述信息 |
data | 成功时为true,错误时为"" |
php请求示例
<?php
//引用config.php
include 'config.php';
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'rank' => 1,
'channelId' => '204140'
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
// 拼接需要签名的参数
$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/auth/upload-white-list?".http_build_query($params);
function post($url, $post_data = '', $timeout = 5){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
if($post_data != ''){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
// 文件不参与签名
$file['file'] = new CURLFile(realpath("test.xls"));
echo post($url, $file);
?>