频道发送管理员聊天信息

接口URL

http://api.polyv.net/live/v3/channel/chat/send

接口说明

1、接口用于获取频道观看条件
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,32位大写MD5值
channellId int 频道ID
content String 聊天信息内容
role String 发送人角色(目前为只提供管理员角色,值为"ADMIN")

响应成功JSON示例:

{
  "code": 200,
  "status": "success",
  "message": "",
  "data": "The message send 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": 400,
    "status": "error",
    "message": "param should not be empty: channelId",
    "data": ""
}
{
    "code": 400,
    "status": "error",
    "message": "param should not be empty: content",
    "data": ""
}
{
    "code": 400,
    "status": "error",
    "message": "param should not be empty: role",
    "data": ""
}

角色类型错误

{
    "code": 400,
    "status": "error",
    "message": "illegal chat role",
    "data": ""
}

请求出错了

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": "The network is error, please try again!"
}

字段说明

参数名 说明
code 请求结果代码,成功为200 错误为400,签名错误为403,接口错误为500
status 请求结果,成功时为"success"错误时为"error"
message 错误信息,请求成功时为空串,错误时错误信息
data 请求成功为数据内容,错误为空串

php请求示例

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

$channelId="183950";
$content="test";
$role='ADMIN';

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

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

$url = "http://api.polyv.net/live/v3/channel/chat/send?appId=".$appId."&channelId=".$channelId."&content=".$content."&role=".$role."&timestamp=".$timestamp."&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;

?>

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

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

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