获取授权和连麦的token(新)

接口URL

http://api.polyv.net/live/v3/channel/common/get-chat-token

接口说明

1、接口用于获取授权和连麦的token
2、接口支持https

支持格式

JSON

请求方式

GET POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道Id
userId String 观看者用户ID
role String 角色,值有:teacher admin guest assistant viewer等
origin String 观看来源

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
"mediaChannelKey": "e2355436235ba12d4c56493b575afed38f9f061d044f54d93c30f01463ffea852a7119c6195c6abf51b4682bc596bf5962eddc6cbf82784a1e5309ac52220ef7e66e4e7eb69a4e80081056972d5a9cb3bb723a0cb090702eef99369d479482b3bad99e5ec50eae5607b82c58da59aac3eada29fe6d753ef358d064ee308e406b3091f5256a77251001f99b6815651f18982da983b58c79d9caedd5ccec3f20ecd3dde7ba370f3c0ca0aa8c3ef088148523019f06e224d030b871da390c4a1a1c646e26684895d544dbba47751c535d07ea765fcf0cdfe8fe3de1538e4fe69eecadfd4a8b431aa4b00bc5dbccdb996ea3b7f962da2ecc21b6b14ba70c33601c53c3aa8d8e4857c111fa076e47e3a6eafc9601b87c079361f2d0f3cb4b31df2ff088ccb9428abe324ecb9e07e2fb8f48e40ab2ef3e119cfd93b15259bfa390938485a8fcd2e200dadeefe15a0516b7f61736cbe5bf48564d100e28ff64f979ebf42eadd3a0f3d58565d1ab619884d78c29",
"token": "71b961e6b2a68cde9559966b2f46d4e0"
}
}

响应字段说明

参数名 说明
code 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data.token 链接接口需要的token值
data.mediaChannelKey 连麦需要的key

响应失败JSON示例:

参数错误

{
    "code": 400,
    "status": "error",
    "message": "param validate error",
    "data": 400
}

未输入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": ""
}

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'userId' => $userId,
  'role' => $role,
  'origin' => $origin,
  'channelId' =>  195770
);

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

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

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

echo $res;
?>

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

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

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

获取频道广告列表

接口URL

http://api.polyv.net/live/v3/channel/advert/list

接口说明

1、提供获取频道轮播广告列表信息,频道广告为空时,获取全局广告
2、支持https

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型 说明
appId string 账号应用下的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channelId int 频道号

操作成功响应示例

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "text": "",
            "img": "//liveimages.videocc.net/uploaded/images/2019/09/ffmgstpk58.png",
            "href": ""
        },
        {
            "text": "123445",
            "img": "",
            "href": ""
        }
    ]
}

操作失败响应示例

签名错误

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

缺少参数 channelId

{
    "code": 400,
    "status": "error"
    "message": "param should not be empty: channelId",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为403,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
data object[] 成功响应数据
text string 文本广告内容
img string 图片广告链接
href string 跳转链接

php请求示例

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

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

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

//接口请求url
$url = "https://api.polyv.net/live/v3/channel/advert/list?appId=".$appId."&sign=".$sign."&timestamp=".$timestamp."&channelId=".$channelId;
//输出接口请求结果
echo file_get_contents($url);

?>

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

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

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

获取授权和连麦的token

接口URL

http://api.polyv.net/live/v3/channel/common/get-token

接口说明

1、接口用于获取授权和连麦的token
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

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

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
"mediaChannelKey": "e2355436235ba12d4c56493b575afed38f9f061d044f54d93c30f01463ffea852a7119c6195c6abf51b4682bc596bf5962eddc6cbf82784a1e5309ac52220ef7e66e4e7eb69a4e80081056972d5a9cb3bb723a0cb090702eef99369d479482b3bad99e5ec50eae5607b82c58da59aac3eada29fe6d753ef358d064ee308e406b3091f5256a77251001f99b6815651f18982da983b58c79d9caedd5ccec3f20ecd3dde7ba370f3c0ca0aa8c3ef088148523019f06e224d030b871da390c4a1a1c646e26684895d544dbba47751c535d07ea765fcf0cdfe8fe3de1538e4fe69eecadfd4a8b431aa4b00bc5dbccdb996ea3b7f962da2ecc21b6b14ba70c33601c53c3aa8d8e4857c111fa076e47e3a6eafc9601b87c079361f2d0f3cb4b31df2ff088ccb9428abe324ecb9e07e2fb8f48e40ab2ef3e119cfd93b15259bfa390938485a8fcd2e200dadeefe15a0516b7f61736cbe5bf48564d100e28ff64f979ebf42eadd3a0f3d58565d1ab619884d78c29",
"token": "71b961e6b2a68cde9559966b2f46d4e0"
}
}

响应字段说明

参数名 说明
code 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data.token 链接接口需要的token值
data.mediaChannelKey 连麦需要的key

响应失败JSON示例:

参数错误

{
    "code": 400,
    "status": "error",
    "message": "param validate error",
    "data": 400
}

未输入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": ""
}

php请求示例

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

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

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

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

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

echo $res;
?>

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

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

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

获取频道的详细设置信息

接口URL

http://api.polyv.net/live/v3/channel/basic/get

接口说明

1、接口用于获取频道的详细设置信息
2、接口支持https

支持格式

JSON

请求方式

GET

请求参数

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

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "channelId": 108888,
        "name": "test111",
        "channelPasswd": "1234",
        "publisher": "主持人",
        "startTime": 0,
        "pageView": 111,
        "likes": 66,
        "coverImg": "//livestatic.videocc.net/uploaded/images/2019/05/fcowsdnzx8.png",
        "splashImg": "//livestatic.videocc.net/uploaded/images/2019/05/fcowsdrak0.png",
        "splashEnabled": "Y",
        "desc": "你好,这个是直播介绍11111",
        "consultingMenuEnabled": "N",
        "maxViewerRestrict": "N",
        "maxViewer": 123,
        "watchStatus": "playback",
        "watchStatusText": "回放中",
        "userCategory": {
            "categoryId": 155224,
            "categoryName": "新建分类测试",
            "userId": "edvf2fpec9",
            "rank": 3
        },
        "authSettings": [
            {
                "channelId": 108888,
                "rank": 1,
                "userId": "edvf2fpec9",
                "globalSettingEnabled": "N",
                "enabled": "Y",
                "authType": "code",
                "authTips": "欢迎观看本直播",
                "payAuthTips": "欢迎观看本次直播",
                "codeAuthTips": "欢迎观看本次直播",
                "infoAuthTips": "欢迎观看本次直播",
                "authCode": "1",
                "qcodeTips": "扫码关注XXX,获得观看码扫码关注XXX",
                "qcodeImg": "",
                "price": 999999.00,
                "watchEndTime": null,
                "validTimePeriod": null,
                "customKey": "c130221c6b",
                "customUri": null,
                "externalKey": "94c7e79aff",
                "externalUri": null,
                "externalRedirectUri": null,
                "directKey": null,
                "trialWatchEnabled": "Y",
                "trialWatchTime": 1,
                "trialWatchEndTime": null
            },
            {
                "channelId": 108888,
                "rank": 2,
                "userId": "edvf2fpec9",
                "globalSettingEnabled": "N",
                "enabled": "Y",
                "authType": "pay",
                "authTips": "欢迎观看本次直播",
                "payAuthTips": "欢迎观看本直播",
                "codeAuthTips": "验证码是1",
                "infoAuthTips": null,
                "authCode": "1",
                "qcodeTips": "",
                "qcodeImg": "",
                "price": 1.00,
                "watchEndTime": null,
                "validTimePeriod": null,
                "customKey": "17040194f4",
                "customUri": null,
                "externalKey": "693d8a540c",
                "externalUri": null,
                "externalRedirectUri": null,
                "directKey": null,
                "trialWatchEnabled": "N",
                "trialWatchTime": 1,
                "trialWatchEndTime": null
            }
        ]
    }
}

响应字段说明

参数名 类型 说明
code int 状态状态码,请求成功时为200
status string 状态值
message string 请求失败时返回的错误值
data ChannelDetailSettingModel 请求失败时为空,请求成功时为频道的详细设置信息

ChannelDetailSettingModel字段说明

参数名 类型 说明
channelId int 频道号
name string 频道名称
channelPasswd string 频道密码
publisher string 主持人名称
startTime long 直播开始时间,关闭时为0,开启时为13位毫秒级时间戳
pageView int 页面累计观看数
likes int 观看页点赞数
coverImg string 频道图标url
splashImg string 频道引导图url
splashEnabled string(取值为Y/N) 引导页开关
desc string 直播介绍
consultingMenuEnabled string(取值为Y/N) 咨询提问开关
maxViewerRestrict string(取值为Y/N) 限制最大在线观看人数开关
maxViewer int 最大在线观看人数
watchStatus string 频道的观看页状态,取值为: 频道状态,取值:live(直播中)、end(直播结束)、playback(回放中)、waiting(等待直播)
watchStatusDesc string 观看页状态描述,直播中,回放中,已结束,未开始
userCategory object 频道所属分类的信息
userCategory.categoryId int 分类ID
userCategory.categoryName string 分类名称
userCategory.rank int 分类的排序值
authSettings List 直播观看条件列表

关于ChannelAuthSetting 的参数说明请参考该接口的成功返回结果:查询直播频道观看条件

响应失败JSON示例:

参数错误

{
    "code": 400,
    "status": "error",
    "message": "param validate error",
    "data": 400
}

未输入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": ""
}

php请求示例

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

$channelId="183950";

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

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

$url = "http://api.polyv.net/live/v3/channel/basic/get?appId=".$appId."&channelId=".$channelId."&timestamp=".$timestamp."&sign=".$sign;

echo file_get_contents($url);

?>

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

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

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

创建并初始化频道

接口URL

http://api.polyv.net/live/v3/channel/basic/create

接口说明

1、接口用于创建频道并进行相关设置
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
basicSetting json 基础设置
authSettings json 观看条件设置

注:这里的appId,timestamp,sign必须通过url传参,json数据通过请求体传参,如:
http://api.polyv.net/live/v3/channel/basic/create?appId={{appId}}&timestamp={{timestamp}}&sign={{sign}}

请求体json示例

{
    "basicSetting": {
        "name": "测试", 
        "channelPasswd": "10086", 
        "maxViewer": 20, 
        "startTime": 1557888134000
    }, 
    "authSettings": [
        {
            "rank": 1, 
            "enabled": "Y", 
            "authType": "external", 
            "externalKey": "L0EjokKI4O", 
            "externalUri": "http://demo.polyv.net/chenwb/live-validate.php"
        }
    ]
}

basicSetting详细说明

参数名 必选 类型 说明
name string 频道名称
channelPasswd string 频道密码,长度不能超过16位
autoPlay int 是否自动播放,0/1,默认1
playerColor string 播放器控制栏颜色,默认:#666666
scene string 直播场景:
alone 活动拍摄
ppt 三分屏
topclass 大班课
categoryId int 新建频道的所属分类,如果不提交,则为默认分类(分类ID可通过“获取直播分类”接口得到)
maxViewer int 最大同时在线人数
startTime long 直播开始时间,13位时间戳
desc string 直播介绍的内容
publisher string 主持人

authSettings详细说明

详细的数据参数,参考 更新观看条件 的请求参数部分

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": {
        "channelId": 323158, 
        "userId": "b0f7041324", 
        "name": "测试", 
        "publisher": null, 
        "description": "", 
        "url": "rtmp://push-c1.videocc.net/recordf/b0f704132420190515115309303", 
        "stream": "b0f704132420190515115309303", 
        "logoImage": "", 
        "logoOpacity": 1, 
        "logoPosition": "tr", 
        "logoHref": "", 
        "coverImage": "", 
        "coverHref": "", 
        "waitImage": "", 
        "waitHref": "", 
        "cutoffImage": "", 
        "cutoffHref": "", 
        "advertType": "NONE", 
        "advertDuration": 0, 
        "advertWidth": 0, 
        "advertHeight": 0, 
        "advertImage": "", 
        "advertHref": "", 
        "advertFlvVid": "", 
        "advertFlvUrl": "", 
        "playerColor": "#FFFFFF", 
        "autoPlay": false, 
        "warmUpFlv": "", 
        "passwdRestrict": false, 
        "passwdEncrypted": "", 
        "isOnlyAudio": "N", 
        "isLowLatency": "N", 
        "m3u8Url": "http://pull-c1.videocc.net/recordf/b0f704132420190515115309303.m3u8?auth_key=1557892389-0-0-d1cab3b24dc910dc22e3ab60915f682b", 
        "m3u8Url1": "", 
        "m3u8Url2": "", 
        "m3u8Url3": "", 
        "channelLogoImage": null, 
        "scene": "topclass", 
        "currentTimeMillis": 1557892389591
    }
}

响应字段说明

参数名 类型 说明
status string 状态值
result object 响应的结果
channelId string 直播频道ID
userId string 直播用户ID
name string 直播频道名称
description string 直播频道描述
url string 直播推流地址
stream string 直播流名称
logoImage string 播放器logo
logoOpacity float Logo不透明度,1表示完全不透明
logoPosition string Logo位置
logoHref string Logo的跳转链接
coverImage string 播放前显示的封面图
coverHref string 封面图的跳转链接
waitImage string 等待推流时的显示图片
waitHref string 等待推流时显示图片的跳转链接
cutoffImage string 切断流时的显示图片
cutoffHref string 切断流时显示图片的跳转链接
advertType string 广告类型
advertDuration string 广告时长
advertWidth string 广告区域宽度
advertHeight string 广告区域高度
advertImage string 图片广告
advertHref string 广告的跳转链接
advertFlvVid string 视频广告ID
advertFlvUrl string 视频广告链接
playerColor string 播放器控制栏颜色
autoPlay boolean 自动播放
warmUpFlv string 一开始的暖场视频
passwdRestrict boolean 观看密码限制,需要输入观看密码才能播放流
passwdEncrypted string 观看密码加密后的密文
isOnlyAudio string 仅推音频流
isLowLatency string 低延迟
m3u8Url string 直播拉流(播放)m3u8地址
m3u8Url1 string 直播拉流(播放)m3u8地址1
m3u8Url2 string 直播拉流(播放)m3u8地址2
m3u8Url3 string 直播拉流(播放)m3u8地址3
currentTimeMillis timestamp 服务器返回的时间戳(毫秒)

响应失败JSON示例:

参数错误

{
    "code": 400,
    "status": "error",
    "message": "param validate error",
    "data": 400
}

未输入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": ""
}

Json格式错误或字段类型不对

{
    "code": 400,
    "status": "error",
    "message": "json format error",
    "data": 400
}

字段说明

参数名 说明
code 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data 成功时为true,错误时为""

php请求示例

<?php
//引用config.php
include '/srv/http/live/config.php';
$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp
);

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

$json = '{"basicSetting":{"name":"测试","channelPasswd":"10086","maxViewer":20},"authSettings":[{"rank":1,"enabled":"Y","authType":"external","externalKey":"L0EjokKI4O","externalUri":"http://demo.polyv.net/chenwb/live-validate.php"}]}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/basic/create?".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);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($post_data)));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

echo post($url,$json);
?>

Java请求示例

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import com.live.util.EncryptionUtils;

public class Demo {

    private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
            .setConnectionRequestTimeout(15000).build();

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/basic/create";
        String appId = "appId";
        String key = "appSecret";
        Map<String, String> map = new HashMap<>();
        String timestamp = Long.toString(System.currentTimeMillis());
        map.put("appId", appId);
        map.put("timestamp", timestamp);

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "{\"basicSetting\":{\"name\":\"测试\",\"channelPasswd\":\"10086\",\"maxViewer\":20," +
                "\"startTime\":\"1\"},\"authSettings\":[{\"rank\":1,\"enabled\":\"Y\",\"authType\":\"external\"," +
                "\"externalKey\":\"L0EjokKI4O\",\"externalUri\":\"http://demo.polyv.net/chenwb/live-validate.php\"}]}";
        String content = sendHttpPost(url, map, body);
        System.out.println(content);

    }

    /**
     * 发送 post请求
     * @param httpUrl 地址
     * @param maps 参数
     */
    public static String sendHttpPost(String httpUrl, Map<String, String> maps, String body) {
        StringBuilder url = new StringBuilder();
        url.append(httpUrl).append("?");
        for (Map.Entry<String, String> map : maps.entrySet()) {
            url.append(map.getKey()).append("=").append(map.getValue()).append("&");
        }
        String urlStr = url.toString().substring(0, url.length() - 1);

        System.out.println(urlStr);
        // 创建httpPost
        HttpPost httpPost = new HttpPost(urlStr);
        try {
            StringEntity entity = new StringEntity(body, Charset.forName("UTF-8"));
            httpPost.setEntity(entity);
        } catch (Exception e) {
            // ...
        }
        return sendHttpPost(httpPost);
    }

    /**
     * 发送Post请求
     * @param httpPost
     * @return
     */
    private static String sendHttpPost(HttpPost httpPost) {
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse response = null;
        HttpEntity entity;
        String responseContent = null;
        try {
            // 创建默认的httpClient实例.
            httpClient = HttpClients.createDefault();
            httpPost.setConfig(requestConfig);
            // 执行请求
            response = httpClient.execute(httpPost);
            entity = response.getEntity();
            responseContent = EntityUtils.toString(entity, "UTF-8");
        } catch (Exception e) {
            // ...
        } finally {
            try {
                // 关闭连接,释放资源
                if (response != null) {
                    response.close();
                }
                if (null != httpPost) {
                    httpPost.releaseConnection();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (IOException e) {
                // ...
            }
        }
        return responseContent;
    }

    /**
     * 根据map里的参数构建加密串
     * @param map
     * @param secretKey
     * @return
     */
    protected static String getSign(Map<String, String> map, String secretKey) {
        Map<String, String> params = paraFilter(map);
        // 处理参数,计算MD5哈希值
        String concatedStr = concatParams(params);
        String plain = secretKey + concatedStr + secretKey;
        String encrypted = EncryptionUtils.md5Hex(plain);

        // 32位大写MD5值
        return encrypted.toUpperCase();
    }

    /**
     * 对params根据key来排序并且以key1=value1&key2=value2的形式拼接起来
     * @param params
     * @return
     */
    private static String concatParams(Map<String, String> params) {
        List<String> keys = new ArrayList<>(params.keySet());
        Collections.sort(keys);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);

            sb.append(key).append(value);
        }

        return sb.toString();
    }

    /**
     * 除去数组中的空值和签名参数
     * @param sArray 签名参数组
     * @return 去掉空值与签名参数后的新签名参数组
     */
    private static Map<String, String> paraFilter(Map<String, String> sArray) {

        Map<String, String> result = new HashMap<>();

        if (sArray == null || sArray.size() <= 0) {
            return result;
        }

        for (String key : sArray.keySet()) {
            String value = sArray.get(key);
            if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
                    || key.equalsIgnoreCase("sign_type")) {
                continue;
            }
            result.put(key, value);
        }

        return result;
    }

}

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

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

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

(子)频道授权登录接口

接口URL

https://live.polyv.net/teacher/auth-login

接口说明

1、接口用于获取token后授权登录
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
channelId string 频道号或子频道号
token string 通过频道token子频道token设置的token串,10秒内且一次验证有效
redirect string 完成授权后重定向地址,使用url编码,如导播台统计分析

响应成功示例:

有填写了redirect,并且验证成功则会重定向到相应的网页,否则默认重定向到相应的后台,验证失败则会重定向到频道登录页

请求示例

https://live.polyv.net/teacher/auth-login?channelId=195770&token=testtoken&redirect=http%3a%2f%2flive.polyv.net%2fnewGuide.html%3fchannel%3d195770
以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

批量删除频道

接口URL

http://api.polyv.net/live/v3/channel/basic/batch-delete

接口说明

1、作用:批量删除直播频道
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channelIds json 频道ID列表,每次最多删除100个频道, 必须放在请求体中

请求体示例

{
    "channelIds": [123001, 123002, 123003]
}

操作成功响应示例

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

操作失败响应示例

留意,如果响应失败,则表示全部频道都失败,不会有部份成功、部份失败的结果

签名错误

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

请求体json格式错误

{
    "code": 400,
    "status": "error"
    "message": "json format error",
    "data": ""
}

channelIds 列表中的频道ID数超过上限(100个)

{
    "code": 400,
    "status": "error"
    "message": "channel batch count over limit",
    "data": ""
}

channelIds 列表中有错误的频道ID(会输出第一个错误的频道ID)

{
    "code": 400,
    "status": "error"
    "message": "channel not found: 123456",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
data boolean 成功时为true

php请求示例

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

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

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

$json = '{
    "channelIds": [123001, 123002, 123003]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/basic/batch-delete?".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);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($post_data)));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

echo post($url,$json);
?>

java请求示例

package com.live;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import com.live.util.EncryptionUtils;

public class Demo {


    private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
            .setConnectionRequestTimeout(15000).build();

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/basic/batch-delete";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "{\"channelIds\":[123001, 123002, 123003]}";
        String content = sendHttpPost(url, map, body);
        System.out.println(content);

    }

    /**
     * 发送 post请求
     * @param httpUrl 地址
     * @param maps 参数
     */
    public static String sendHttpPost(String httpUrl, Map<String, String> maps, String body) {
        StringBuilder url = new StringBuilder();
        url.append(httpUrl).append("?");
        for (Map.Entry<String, String> map : maps.entrySet()) {
            url.append(map.getKey()).append("=").append(map.getValue()).append("&");
        }
        String urlStr = url.toString().substring(0, url.length() - 1);

        System.out.println(urlStr);
        // 创建httpPost
        HttpPost httpPost = new HttpPost(urlStr);
        try {
            StringEntity entity = new StringEntity(body, Charset.forName("UTF-8"));
            httpPost.setEntity(entity);
        } catch (Exception e) {
            // ...
        }
        return sendHttpPost(httpPost);
    }

    /**
     * 发送Post请求
     * @param httpPost
     * @return
     */
    private static String sendHttpPost(HttpPost httpPost) {
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse response = null;
        HttpEntity entity;
        String responseContent = null;
        try {
            // 创建默认的httpClient实例.
            httpClient = HttpClients.createDefault();
            httpPost.setConfig(requestConfig);
            // 执行请求
            response = httpClient.execute(httpPost);
            entity = response.getEntity();
            responseContent = EntityUtils.toString(entity, "UTF-8");
        } catch (Exception e) {
            // ...
        } finally {
            try {
                // 关闭连接,释放资源
                if (response != null) {
                    response.close();
                }
                if (null != httpPost) {
                    httpPost.releaseConnection();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (IOException e) {
                // ...
            }
        }
        return responseContent;
    }

    /**
     * 根据map里的参数构建加密串
     * @param map
     * @param secretKey
     * @return
     */
    protected static String getSign(Map<String, String> map, String secretKey) {
        Map<String, String> params = paraFilter(map);
        // 处理参数,计算MD5哈希值
        String concatedStr = concatParams(params);
        String plain = secretKey + concatedStr + secretKey;
        String encrypted = EncryptionUtils.md5Hex(plain);

        // 32位大写MD5值
        return encrypted.toUpperCase();
    }

    /**
     * 对params根据key来排序并且以key1=value1&key2=value2的形式拼接起来
     * @param params
     * @return
     */
    private static String concatParams(Map<String, String> params) {
        List<String> keys = new ArrayList<>(params.keySet());
        Collections.sort(keys);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);

            sb.append(key).append(value);
        }

        return sb.toString();
    }

    /**
     * 除去数组中的空值和签名参数
     * @param sArray 签名参数组
     * @return 去掉空值与签名参数后的新签名参数组
     */
    private static Map<String, String> paraFilter(Map<String, String> sArray) {

        Map<String, String> result = new HashMap<>();

        if (sArray == null || sArray.size() <= 0) {
            return result;
        }

        for (String key : sArray.keySet()) {
            String value = sArray.get(key);
            if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
                    || key.equalsIgnoreCase("sign_type")) {
                continue;
            }
            result.put(key, value);
        }

        return result;
    }
}

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

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

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

批量创建频道

接口URL

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

接口说明

1、作用:批量创建直播频道
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channels json 频道列表,每次最多创建100个频道, 必须放在请求体中

请求体示例

{
    "channels": [
        {
            "name": "abc",
            "channelPasswd": "xyz"
        },
        {
            "name": "def",
            "channelPasswd": "xyz",
            "autoPlay": 0,
            "playerColor": "#454545",
            "scene": "ppt",
            "categoryId": 123
        }
    ]
}

请求体字段说明

参数名 必选 类型 说明
name string 频道名称
channelPasswd string 频道密码
courseId string 课程号
autoPlay int 是否自动播放,0/1,默认1
注意,如果该值为空,则该频道会使用全局的“功能开关设置”。
如果非空,则会使用频道的“功能开关设置”。
playerColor string 播放器控制栏颜色,默认:#666666
scene string 直播场景:
alone 活动拍摄
ppt 三分屏
topclass 大班课
categoryId int 新建频道的所属分类,如果不提交,则为默认分类(分类ID可通过“获取直播分类”接口得到)

操作成功响应示例

{
    "code": 200,
    "status": "success"
    "message": "",
    "data": {
        "channels": [
            {
                "channelId": 123456,
                "userId": "e6b23c6f51",
                "name": "abc",
                "publisher": null,
                "description": "",
                "url": "rtmp://push2.videocc.net/recordfe/e6b23c6f5120180813142756453",
                "stream": "e6b23c6f5120180813142756453",
                "logoImage": "",
                "logoOpacity": 1.0,
                "logoPosition": "",
                "logoHref": "",
                "coverImage": "",
                "coverHref": "",
                "waitImage": "",
                "waitHref": "",
                "cutoffImage": "",
                "cutoffHref": "",
                "advertType": "IMAGE",
                "advertDuration": 5,
                "advertWidth": 0,
                "advertHeight": 0,
                "advertImage": "",
                "advertHref": "",
                "advertFlvVid": "",
                "advertFlvUrl": "",
                "playerColor": "#666666",
                "autoPlay": true,
                "warmUpFlv": "",
                "passwdRestrict": false,
                "passwdEncrypted": "",
                "isOnlyAudio": "N",
                "isLowLatency": "N",
                "m3u8Url": "http://pullh.videocc.net/recordfe/e6b23c6f5120180813142756453/playlist.m3u8",
                "m3u8Url1": "",
                "m3u8Url2": "",
                "m3u8Url3": "",
                "currentTimeMillis": 1534141677347
            }
        ]
    }
}

操作失败响应示例

留意,如果响应失败,则表示全部频道都失败,不会有部份成功、部份失败的结果

签名错误

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

请求体json格式错误

{
    "code": 400,
    "status": "error"
    "message": "json format error",
    "data": ""
}

channels 列表中的频道数超过上限(100个)

{
    "code": 400,
    "status": "error"
    "message": "channel batch count over limit",
    "data": ""
}

现有频道数加上新建频道数的总数,超过用户可创建的频道总数

{
    "code": 400,
    "status": "error"
    "message": "channel count reached the limit",
    "data": ""
}

频道名称或者频道密码为空

{
    "code": 400,
    "status": "error"
    "message": "param should not be empty: name",
    "data": ""
}

{
    "code": 400,
    "status": "error"
    "message": "param should not be empty: channelPasswd",
    "data": ""
}

courseId 长度超过限制(100个字符)

{
    "code": 400,
    "status": "error"
    "message": "param length is incorrect: courseId",
    "data": ""
}

自动播放 autoPlay 错误(不是1或者0)

{
    "code": 400,
    "status": "error"
    "message": "param validate error",
    "data": ""
}

播放器颜色 playerColor 错误(正确的颜色值例如 #666666)

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

直播场景 scene 错误

{
    "code": 400,
    "status": "error"
    "message": "invalid live scene",
    "data": ""
}

频道分类ID categoryId 错误

{
    "code": 400,
    "status": "error"
    "message": "illegal category id: categoryId",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
channelId string 直播频道ID
userId string 直播用户ID
name string 直播频道名称
description string 直播频道描述
url string 直播推流地址
stream string 直播流名称
logoImage string 播放器logo
logoOpacity float Logo不透明度,1 表示完全不透明,0 表示完全透明
logoPosition string logo位置:
tl 左上,
tr 右上,
bl 左下,
br 右下。
logoHref string Logo的跳转链接
coverImage string 播放前显示的封面图
coverHref string 封面图的跳转链接
waitImage string 等待推流时的显示图片
waitHref string 等待推流时显示图片的跳转链接
cutoffImage string 切断流时的显示图片
cutoffHref string 切断流时显示图片的跳转链接
advertType string 片头广告类型:
NONE 无广告,
IMAGE 图片,
FLV 视频。
advertDuration string 广告时长(秒)
advertWidth string 广告区域宽度(像素)
advertHeight string 广告区域高度(像素)
advertImage string 图片广告
advertHref string 广告的跳转链接
advertFlvVid string 视频广告ID
advertFlvUrl string 视频广告链接
playerColor string 播放器控制栏颜色,例如 #666666
autoPlay boolean 是否自动播放
warmUpFlv string 暖场视频链接
passwdRestrict boolean 观看密码限制,需要输入观看密码才能播放流
passwdEncrypted string 观看密码加密后的密文
isOnlyAudio string Y 音频模式,
N 普通模式。
isLowLatency string 低延迟
m3u8Url string 直播拉流(播放)m3u8地址
m3u8Url1 string 直播拉流(播放)m3u8地址1
m3u8Url2 string 直播拉流(播放)m3u8地址2
m3u8Url3 string 直播拉流(播放)m3u8地址3
currentTimeMillis timestamp 当前时间戳(毫秒)

php请求示例

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

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

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

$json = '{
    "channels": [{
        "name": "abc",
        "channelPasswd": "xyz"
    }]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/basic/batch-create?".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);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($post_data)));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

echo post($url,$json);
?>

java请求示例

package com.live;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import com.live.util.EncryptionUtils;

public class Demo {


    private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
            .setConnectionRequestTimeout(15000).build();

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/basic/batch-create";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "{\"channels\":[{\"name\": \"abc\", \"channelPasswd\": \"xyz\"}]}";
        String content = sendHttpPost(url, map, body);
        System.out.println(content);

    }

    /**
     * 发送 post请求
     * @param httpUrl 地址
     * @param maps 参数
     */
    public static String sendHttpPost(String httpUrl, Map<String, String> maps, String body) {
        StringBuilder url = new StringBuilder();
        url.append(httpUrl).append("?");
        for (Map.Entry<String, String> map : maps.entrySet()) {
            url.append(map.getKey()).append("=").append(map.getValue()).append("&");
        }
        String urlStr = url.toString().substring(0, url.length() - 1);

        System.out.println(urlStr);
        // 创建httpPost
        HttpPost httpPost = new HttpPost(urlStr);
        try {
            StringEntity entity = new StringEntity(body, Charset.forName("UTF-8"));
            httpPost.setEntity(entity);
        } catch (Exception e) {
            // ...
        }
        return sendHttpPost(httpPost);
    }

    /**
     * 发送Post请求
     * @param httpPost
     * @return
     */
    private static String sendHttpPost(HttpPost httpPost) {
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse response = null;
        HttpEntity entity;
        String responseContent = null;
        try {
            // 创建默认的httpClient实例.
            httpClient = HttpClients.createDefault();
            httpPost.setConfig(requestConfig);
            // 执行请求
            response = httpClient.execute(httpPost);
            entity = response.getEntity();
            responseContent = EntityUtils.toString(entity, "UTF-8");
        } catch (Exception e) {
            // ...
        } finally {
            try {
                // 关闭连接,释放资源
                if (response != null) {
                    response.close();
                }
                if (null != httpPost) {
                    httpPost.releaseConnection();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (IOException e) {
                // ...
            }
        }
        return responseContent;
    }

    /**
     * 根据map里的参数构建加密串
     * @param map
     * @param secretKey
     * @return
     */
    protected static String getSign(Map<String, String> map, String secretKey) {
        Map<String, String> params = paraFilter(map);
        // 处理参数,计算MD5哈希值
        String concatedStr = concatParams(params);
        String plain = secretKey + concatedStr + secretKey;
        String encrypted = EncryptionUtils.md5Hex(plain);

        // 32位大写MD5值
        return encrypted.toUpperCase();
    }

    /**
     * 对params根据key来排序并且以key1=value1&key2=value2的形式拼接起来
     * @param params
     * @return
     */
    private static String concatParams(Map<String, String> params) {
        List<String> keys = new ArrayList<>(params.keySet());
        Collections.sort(keys);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);

            sb.append(key).append(value);
        }

        return sb.toString();
    }

    /**
     * 除去数组中的空值和签名参数
     * @param sArray 签名参数组
     * @return 去掉空值与签名参数后的新签名参数组
     */
    private static Map<String, String> paraFilter(Map<String, String> sArray) {

        Map<String, String> result = new HashMap<>();

        if (sArray == null || sArray.size() <= 0) {
            return result;
        }

        for (String key : sArray.keySet()) {
            String value = sArray.get(key);
            if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
                    || key.equalsIgnoreCase("sign_type")) {
                continue;
            }
            result.put(key, value);
        }

        return result;
    }
}

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

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

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

修改频道详情

接口URL

http://api.polyv.net/live/v3/channel/detail/update

接口说明

1、接口用于设置频道的基本详情相关设置
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
field string 要更新的字段名称:password 密码 scene 直播场景 maxViewer 最大同时在线人数
value string 新的字段值,除设置无限制最大观看人数时可不提交,其他情况都为必填

直播场景的取值分别为:alone(活动拍摄),ppt(PPT三分频直播),topclass(大班课直播),设置前,请确认您的套餐是否包含对应场景

响应成功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 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data 成功时为true,错误时为""

php请求示例

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

$params = array(
  'appId' => "填写获取到的appId",
  'timestamp' => "填写13位时间戳",
  'channelId' => "填写频道号",
  'field' => "password",
  'value' => "abcdefg"
);

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


$url="http://api.polyv.net/live/v3/channel/detail/update";

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);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

$params["sign"] = $sign;
echo post($url, http_build_query($params));
?>

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

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

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

设置子频道单点登陆token

接口URL

https://api.polyv.net/live/v2/channels/{accountId}/set-account-token

接口说明

1、设置子频道单点登陆的token
2、接口支持https协议
3、接口URL中的{account}为 子频道ID

支持格式

JSON

请求方式

GET,POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
token string 唯一的字符串
sign string 签名,为32位大写的MD5值

响应成功JSON示例:

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

响应失败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 请求状态响应码
status 请求状态
message 错误信息
data 成功时候返回,success

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$accountlId = "001127075";
$token = "skudjjdkkkkk";

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

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

//接口请求url
$url = "https://api.polyv.net/live/v2/channels/$accountId/set-account-token?appId=$appId&timestamp=$timestamp&token=$token&sign=$sign";

//输出接口请求结果
echo file_get_contents($url);

?>

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

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

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