获取授权和连麦的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...