设置外部授权

接口URL

http://api.polyv.net/live/v2/channelSetting/{userId}/auth-external

接口说明

1、作用:设置直播外部授权
2、接口URL中的{userId}为 直播账号ID
3、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
channelId int 频道ID,提交后对某频道ID设置,不提交则对账号下所有频道ID进行设置
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
externalUri string 获取用户信息接口地址
sign string 签名,32位大写MD5值

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
    {
        "channelId": 108888,
        "secretKey": "zBUnUpZWl2"
    }
    ]
}

响应失败JSON示例:

未输入appId

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

appId不正确或userId输入错误

{
    "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": 404,
    "status": "error",
    "message": "channel not found.",
    "data": ""
}

频道配置错误

{
    "code": 403,
    "status": "error",
    "message": "operation forbidden.",
    "data": ""
}

其他错误

{
    "code": 400,
    "status": "error",
    "message": "unknow error",
    "data": ""
}

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
channelId 设置的频道号
secretKey 频道号对应外部授权的secretKey

请求示例

<?php


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


//接口需要的参数(非sign)赋值

$channelId="108888";
$userId="edvf2fpec9";
$externalUri = "http://mywebsite.com/myDefinedUrl.php"; //自定义授权地址


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

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


$url="http://api.live.polyv.net/v2/channelSetting/$userId/auth-external";

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;
}

$post_data = array(
  'sign' => $sign,
  'appId' => $appId,
  'channelId' => $channelId,
  'externalUri' => $externalUri,
  'timestamp' => $timestamp
);
echo post($url, $post_data);
?>

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

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

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