获取频道实时在线人数

接口URL

http://api.polyv.net/live/v1/statistics/{channelId}/realtime

接口说明

1、在直播中,获取实时观看的人数
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级(兼容10位秒级)时间戳,3分钟内有效
userId string 直播账号ID
sign string 签名,为32位大写的MD5值

响应成功JSON示例:

{
  status: "success",
  result: [
    {
      time: "04:01:38",
      count: "0"
    },
    {
      time: "04:01:30",
      count: "1"
    },
    {
      time: "04:01:22",
      count: "2"
    },
    {
      time: "04:01:14",
      count: "2"
    },
    {
      time: "04:01:06",
      count: "2"
    },
    {
      time: "04:00:58",
      count: "1"
    },
    {
      time: "04:00:50",
      count: "1"
    },
    {
      time: "04:00:42",
      count: "2"
    },
    {
      time: "04:00:34",
      count: "2"
    },
    {
      time: "04:00:26",
      count: "2"
    },
    {
      time: "04:00:18",
      count: "1"
    },
    {
      time: "04:00:10",
      count: "2"
    },
    {
      time: "04:00:02",
      count: "2"
    },
    {
      time: "03:59:54",
      count: "3"
    },
    {
      time: "03:59:46",
      count: "2"
    }
  ]
}

响应异常JSON示例:

{
   code: "invalid_argument",
   msg: "userId is blank."
}

字段说明

参数名 类型 说明
status string 状态值
result string 相应的结果
time string 统计的时间点(时间格式:12H)
count string 某个时间点实时观看人数

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$userId = "XXXXXXXX";
$channelId = "127073";

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

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

//接口请求url
$url = "http://api.live.polyv.net/v1/statistics/$channelId/realtime?appId=".$appId."&timestamp=".$timestamp."&userId=".$userId."&sign=".$sign;

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

?>

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

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

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