高级分析–根据观众id查询观众分析结果

接口URL

http://api.polyv.net/v2/advance/viewer/{userid}

接口说明

高级分析--根据观众id查询观众分析结果

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
ptime true string 当前时间的毫秒级时间戳(13位),30分钟内有效
sign true string 签名
userid true string 用户id(拼接在url,无需另外传参数)
viewerId true string 观众id

注意事项

所有有值的参数,按照字母排序方式以key=value&key=value的格式串起来,最后拼上secretkey,以SHA-1方式加密并全部大写化。(注意,当参数没有传递,或者传递了空值,sign不需要将此参数计算进去)

例如:api传递了ptime,vid。ptime为1,vid为test1,userid对应用户的secretkey为test2
则sign的值为:ptime=1&vid=test1test2经过SHA-1加密后大写化为: C2B1558D697EA3AF4ED2FC90152751860C1E2163。

返回错误结果JSON示例

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

返回正确结果JSON示例

{
  "code": 200,
  "status": "success",
  "message": "success",
  "data": {
    "userId": "xxxx",
    "viewerId": "观众id",
    "viewerNickName": "观众昵称",
    "viewerAatar": null,
    "ip": "127.0.0.1",
    "firstWatchTime": 1547020140000,
    "lastWatchTime": 1548148547000,
    "totalVideoCount": 6,
    "totalWatchDuration": 1870,
    "avgCompletionRate": 0.519
  }
}

返回结果data表示成功修改的数量.

字段说明

字段 说明
code 返回码
status 返回状态
message 返回信息
data 操作结果

数据对象字段说明

字段 说明
userId 用户id
viewerId 观众id
viewerNickName 观众昵称
viewerAatar 观众头像
ip ip地址
firstWatchTime 首次观看时间
lastWatchTime 最后观看时间
totalVideoCount 观看视频总数
totalWatchDuration 观众总时长(秒)
avgCompletionRate 平均观看完成度

响应代码与响应信息对应

code message data 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. ptime超出当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串错误
401 viewerId is blank. viewerId为空
402 cannot find the viewer analytics data. 查不到对应的观众分析数据
403 get viewer analytics failed. 查询观众分析数据失败
500 get viewer analytics failed. please check the backend log 后台抛异常
200 success 查询到的数据 查询成功

PHP示例代码

<?php
header("Content-type: text/html; charset=utf-8");
$userid="3828390191";
//$jsonp="a";
$ptime=time()*1000;//13位
$viewerId="观众id";
$secretkey="secretkey";
if(empty($jsonp)){
  $str="ptime=".$ptime."&viewerId=".$viewerId.$secretkey;
}else{
  $str="jsonp=".$jsonp."&ptime=".$ptime."&viewerId=".$viewerId.$secretkey;
}
echo $str.'';
$hash=strtoupper(sha1($str));
echo $hash.'';
$url="http://api.polyv.net/v2/advance/viewer/{$userid}?viewerId={$viewerId}&ptime={$ptime}&sign={$hash}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

"ptime" = "1493188350000"
"playauth" = "1"

2、将请求参数按照参数名字典顺序排列

"playauth" = "1"
"ptime" = "1493188350000"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

playauth=1&ptime=1493188350000tIQp4ATe9Z

4、生成签名sign

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

高级分析–根据视频id查询视频分析数据

接口URL

http://api.polyv.net/v2/advance/video/{userid}

接口说明

高级分析--根据视频id查询视频分析结果

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
ptime true string 当前时间的毫秒级时间戳(13位),30分钟内有效
sign true string 签名
userid true string 用户id(拼接在url,无需另外传参数)
vid true string 视频id

注意事项

所有有值的参数,按照字母排序方式以key=value&key=value的格式串起来,最后拼上secretkey,以SHA-1方式加密并全部大写化。(注意,当参数没有传递,或者传递了空值,sign不需要将此参数计算进去)

例如:api传递了ptime,vid。ptime为1,vid为test1,userid对应用户的secretkey为test2
则sign的值为:ptime=1&vid=test1test2经过SHA-1加密后大写化为: C2B1558D697EA3AF4ED2FC90152751860C1E2163。

返回错误结果JSON示例

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

返回正确结果JSON示例

{
  "code": 200,
  "status": "success",
  "message": "success",
  "data": {
    "videoId": "xxxxxxxxxxxxxxxx",
    "videoName": "视频名称m",
    "duration": 100,
    "playTimes": 665,
    "uniqueViewerCount": 614,
    "avgCompletionRate": 0.49,
    "viewHeatmap": "[\"0-20:662\",\"21-100:665\"]",
    "uniqueViewHeatmap": "[\"0-20:614\",\"21-100:615\"]"
  }
}

返回结果data表示成功修改的数量.

字段说明

字段 说明
code 返回码
status 返回状态
message 返回信息
data 操作结果

数据对象字段说明

字段 说明
videoId 视频id
videoName 视频名称
duration 视频时长
playTimes 播放次数
uniqueViewerCount 唯一观众数
avgCompletionRate 平均观看完成度
viewHeatmap 观看热力图,例如[\"0-20:662\",\"21-100:665\"]代表视频内容的0~20秒有662次观看,21~100秒有665次观看
uniqueViewHeatmap 唯一观看热力图,例如[\"0-20:614\",\"21-100:615\"]代表视频内容的0~20秒有614个观众观看,21~100秒有615个观众观看

响应代码与响应信息对应

code message data 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. ptime超出当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串错误
401 vid is blank. 视频id为空
402/403 cannot find this video data. 查不到视频分析数据
404 get video analytics detail failed. 后台获取数据失败
500 get play list failed. please check the backend log. 后台抛异常
200 success 查询到的数据 查询成功

PHP示例代码

<?php
header("Content-type: text/html; charset=utf-8");
$userid="3828390191";
//$jsonp="a";
$ptime=time()*1000;//13位
$vid="视频id";
$secretkey="secretkey";
if(empty($jsonp)){
  $str="ptime=".$ptime."&vid=".$vid.$secretkey;
}else{
  $str="jsonp=".$jsonp."&ptime=".$ptime."&vid=".$vid.$secretkey;
}
echo $str.'';
$hash=strtoupper(sha1($str));
echo $hash.'';
$url="http://api.polyv.net/v2/advance/video/{$userid}?vid={$vid}&ptime={$ptime}&sign={$hash}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

"ptime" = "1493188350000"
"playauth" = "1"

2、将请求参数按照参数名字典顺序排列

"playauth" = "1"
"ptime" = "1493188350000"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

playauth=1&ptime=1493188350000tIQp4ATe9Z

4、生成签名sign

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

高级分析-分页查询观看行为列表

接口URL

http://api.polyv.net/v2/advance/play/{userid}

接口说明

高级分析--根据条件分页查询观看行为列表

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
ptime true string 当前时间的毫秒级时间戳(13位),30分钟内有效
sign true string 签名
userid true string 用户id(拼接在url,无需另外传参数)
start false string 开始时间,格式为yyyy-MM-dd或者yyyy-MM-dd HH:mm:ss,查询范围不超过31天
end false string 结束时间,格式为yyyy-MM-dd或者yyyy-MM-dd HH:mm:ss,查询范围不超过31天
pageSize false int 每页取多少条数据(最大为20,超过则默认取20条数据)
viewerId false string 观众id
viewerName false string 观众昵称
vid false string 视频id
token false string 下一页的凭证,从当前页的返回数据里获取,第一页不需要传

时间参数说明

  • 查询的时间跨度不超过31天;
  • 当start有值而end为空时,返回开始日期后31天后的数据;
  • 当start为空而end不为空时,返回结束日期前31天内的数据;
  • 当start、end参数均为空时,返回最近31天的数据。

注意事项

所有有值的参数,按照字母排序方式以key=value&key=value的格式串起来,最后拼上secretkey,以SHA-1方式加密并全部大写化。(注意,当参数没有传递,或者传递了空值,sign不需要将此参数计算进去)

例如:api传递了ptime,vid。ptime为1,vid为test1,userid对应用户的secretkey为test2
则sign的值为:ptime=1&vid=test1test2经过SHA-1加密后大写化为: C2B1558D697EA3AF4ED2FC90152751860C1E2163。

返回错误结果JSON示例

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

返回正确结果JSON示例

{
  "code": 200,
  "status": "success",
  "message": "success",
  "data": {
    "pageSize": 3,
    "contents": [
      {
        "startTime": "2019-10-01 11:12:05",
        "videoId": "xxxxxx",
        "videoName": "test video",
        "videoImage": "//img.videocc.net/uimage/xxxxxx.jpg",
        "videoDuration": 100,
        "deviceClass": "Phone",
        "osName": "Android",
        "osVersion": "Unknown",
        "agentName": "Unknown",
        "agentVersion": "Unknown",
        "referer": "N/A",
        "ip": "127.0.0.1",
        "country": "中国",
        "province": "广东",
        "city": "未知",
        "isp": "中国电信",
        "viewerId": "1234567890",
        "viewerNickName": "N/A",
        "viewerAvatar": "N/A",
        "totalVideoCount": 100,
        "heatmap": "[\"0-1:1\",\"2-3:1\"]",
        "completionRate": 0.02,
        "status": 61
      },
      {
        "startTime": "2019-10-01 11:12:05",
        "videoId": "xxxxxx",
        "videoName": "test video",
        "videoImage": "//img.videocc.net/uimage/xxxxxx.jpg",
        "videoDuration": 100,
        "deviceClass": "Phone",
        "osName": "Android",
        "osVersion": "Unknown",
        "agentName": "Unknown",
        "agentVersion": "Unknown",
        "referer": "N/A",
        "ip": "127.0.0.1",
        "country": "中国",
        "province": "广东",
        "city": "未知",
        "isp": "中国电信",
        "viewerId": "1234567890",
        "viewerNickName": "N/A",
        "viewerAvatar": "N/A",
        "totalVideoCount": 100,
        "heatmap": "[\"0-50:1\"]",
        "completionRate": 0.5,
        "status": 61
      },
      {
        "startTime": "2019-10-01 11:12:05",
        "videoId": "xxxxxx",
        "videoName": "test video",
        "videoImage": "//img.videocc.net/uimage/xxxxxx.jpg",
        "videoDuration": 100,
        "deviceClass": "Phone",
        "osName": "Android",
        "osVersion": "Unknown",
        "agentName": "Unknown",
        "agentVersion": "Unknown",
        "referer": "N/A",
        "ip": "127.0.0.1",
        "country": "中国",
        "province": "广东",
        "city": "未知",
        "isp": "中国电信",
        "viewerId": "1234567890",
        "viewerNickName": "N/A",
        "viewerAvatar": "N/A",
        "totalVideoCount": 100,
        "heatmap": "[\"0-50:1\"]",
        "completionRate": 0.5,
        "status": 61
      }
    ],
    "token": "xxxxxxxxxxxxxxx",
    "hasNextPage": true
  }
}

返回结果data表示成功修改的数量.

字段说明

字段 说明
code 返回码
status 返回状态
message 返回信息
data 操作结果

数据对象字段说明

字段 说明
startTime 首次观看日期
videoId 视频id
videoName 视频名称
videoImage 视频首图(没有添加协议头)
videoDuration 视频时长
deviceClass 设备名称
osName 操作系统
agentName 终端名称
agentVersion 终端版本
referer 来源
ip ip地址
country 国家
province 省份
city 地区
isp 运营商
viewerid 观众id
viewerNickName 观众昵称
viewerAvatar 观众头像
totalVideoCount 观众看的视频总量
heatmap 热力图(["0-1:1","3-4:2"]表示视频的0到1秒有1次观看,3到4秒有2次观看)
completionRate 观看完成度
status 视频的状态
token 查询下一页时传的凭证
hasNextPagetoken 是否有下一页

响应代码与响应信息对应

code message data 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. ptime超出当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串错误
401 start date or end date is illegal. start或者end参数格式有问题
402 date range exceeds 31 days. start和end参数相差超过31天
403 get play list error. 后台获取数据失败
500 get play list failed. please check the backend log. 后台抛异常
200 success 查询到的数据 查询成功

PHP示例代码

<?php
header("Content-type: text/html; charset=utf-8");
$userid="3828390191";
//$jsonp="a";
$ptime=time()*1000;//13位
$start="2019-10-15";
$secretkey="tIQp4ATe9Z";
if(empty($jsonp)){
  $str="start=".$start."&ptime=".$ptime.$secretkey;
}else{
  $str="jsonp=".$jsonp."&start=".$start."&ptime=".$ptime.$secretkey;
}
echo $str.'';
$hash=strtoupper(sha1($str));
echo $hash.'';
$url="http://api.polyv.net/v2/advance/play/{$userid}?start={$start}&ptime={$ptime}&sign={$hash}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

"ptime" = "1493188350000"
"playauth" = "1"

2、将请求参数按照参数名字典顺序排列

"playauth" = "1"
"ptime" = "1493188350000"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

playauth=1&ptime=1493188350000tIQp4ATe9Z

4、生成签名sign

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

获取视频观看完成度

接口URL

https://api.polyv.net/v2/video/engagement/{userid}/get

接口说明

获取学员对于某个视频的观看完成度

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
vid true string 视频vid
viewerId true string 自定义观众id

返回结果

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

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
data 已完成进度比例

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 vid invalid. 视频vid错误
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
400 video not found 视频不存在
400 permission limit 没有权限访问api

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$secretkey="用户$secretkey";
$params = array(
    'ptime' => time()*1000,
    'vid' => '视频vid',
    'viewerId' => '学员id'
);

# 创建排序后的字典
foreach ($params as $key=>$value){
    $arr[$key] = $key;
}
sort($arr);
$str='';
$length=count($arr);
foreach ($arr as $k => $v) {
    $str = $str.$v.'='.$params[$v];
    if($k < $length-1) {
      $str = $str.'&';
    }
}
$hash=strtoupper(sha1($str.$secretkey));

$params['sign']=$hash;
$url="http://api.polyv.net/v2/video/engagement/${userid}/get?".http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询视频某个时段的播放流量统计数据

接口URL

https://api.polyv.net/v2/traffic/{userid}/video/{vid}

接口说明

查询给定的日期区间内视频每天消耗的流量
自2018年7月10日起,才可以统计到单个视频的移动端流量数据,在此之前没有移动端流量数据

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
vid true string 视频vid,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": [
    {
      "currentDay": "2018-07-14", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-15", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-16", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-17", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-18", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-19", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }, 
    {
      "currentDay": "2018-07-20", 
      "pcFlowSize": 0, 
      "mobileFlowSize": 0, 
      "totalFlowSize": 0
    }
  ]
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
currentDay 日期
pcFlowSize PC端消耗流量,单位字节
mobileFlowSize 移动端消耗流量,单位字节
totalFlowSize 总流量消耗,单位字节

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 vid invalid. 视频id错误
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$dr="7days";
$ptime=time()*1000;//13位
$secretkey="填写secretkey";
$str="dr=".$dr."&ptime=".$ptime.$secretkey;
$vid="b0f704132434cfe3fe8366c59f3875c0_b";

$hash=strtoupper(sha1($str));
$url="https://api.polyv.net/v2/traffic/$userid/video/$vid?ptime=$ptime&sign=$hash&dr=$dr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询单个视频的观看热点统计数据

接口URL

https://api.polyv.net/v2/videohot/{userid}

接口说明

按照日期区间或时间段查询单个视频的观看热点统计数据

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
vid true string 视频vid
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": [
    {
      "second": 1, 
      "viewcount": 0
    }, 
    {
      "second": 7, 
      "viewcount": 1
    }
  ]
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
second 视频时长
viewcount 播放量

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 vid invalid. 视频vid错误
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$dr="this_year";
$vid="9f033b6d5bbc0e9230afae7c7c15d055_9";
$ptime=time()*1000;//13位
$secretkey="填写secretKey";
$str="dr=".$dr."&ptime=".$ptime."&vid=".$vid.$secretkey;

$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/videohot/$userid?ptime=$ptime&sign=$hash&dr=$dr&vid=$vid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询视频的观看比例统计数据

接口URL

https://api.polyv.net/v2/play-ratio/{userid}

接口说明

查询单个视频或全部视频在一定时间范围内的观看比例统计数据

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
vid false string 视频vid,不填为查询用户维度
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": [
    {
      "percentage": "0-10", 
      "playCount": 13
    }, 
    {
      "percentage": "10-20", 
      "playCount": 7
    }, 
    {
      "percentage": "20-30", 
      "playCount": 1
    }, 
    {
      "percentage": "30-40", 
      "playCount": 1
    }, 
    {
      "percentage": "40-50", 
      "playCount": 3
    }, 
    {
      "percentage": "50-60", 
      "playCount": 1
    }, 
    {
      "percentage": "60-70", 
      "playCount": 1
    }, 
    {
      "percentage": "70-80", 
      "playCount": 0
    }, 
    {
      "percentage": "80-90", 
      "playCount": 0
    }, 
    {
      "percentage": "90-100", 
      "playCount": 0
    }
  ]
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
percentage 观看比例范围
playCount 观看数量

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 vid invalid. 视频id错误
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$dr="7days";
$ptime=time()*1000;//13位
$secretkey="填写secretkey";
$vid="视频vid";
$str="dr=".$dr."&ptime=".$ptime."&vid=".$vid.$secretkey;

$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/play-ratio/$userid?ptime=$ptime&sign=$hash&dr=$dr&vid=$vid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询视频的播放时长统计数据

接口URL

https://api.polyv.net/v2/play-duration/{userid}

接口说明

按照日期区间或时段查询视频播放时长统计数据

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
vid false string 视频vid,不传为查询用户级别统计
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": [
    {
      "currentDay": "2018-07-03", 
      "pcPlayDuration": 260, 
      "formatPcPlayDuration": "00:04:20", 
      "pcPlayDurationVideoAvg": 22, 
      "formatPcPlayDurationVideoAvg": "00:00:22", 
      "pcPlayDurationPersonAvg": 130, 
      "formatPcPlayDurationPersonAvg": "00:02:10", 
      "mobilePlayDuration": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDurationVideoAvg": 0, 
      "formatMobilePlayDurationVideoAvg": "00:00:00", 
      "mobilePlayDurationPersonAvg": 0, 
      "formatMobilePlayDurationPersonAvg": "00:00:00"
    }, 
    {
      "currentDay": "2018-07-04", 
      "pcPlayDuration": 0, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDurationVideoAvg": 0, 
      "formatPcPlayDurationVideoAvg": "00:00:00", 
      "pcPlayDurationPersonAvg": 0, 
      "formatPcPlayDurationPersonAvg": "00:00:00", 
      "mobilePlayDuration": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDurationVideoAvg": 0, 
      "formatMobilePlayDurationVideoAvg": "00:00:00", 
      "mobilePlayDurationPersonAvg": 0, 
      "formatMobilePlayDurationPersonAvg": "00:00:00"
    }, 
    {
      "currentDay": "2018-07-05", 
      "pcPlayDuration": 0, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDurationVideoAvg": 0, 
      "formatPcPlayDurationVideoAvg": "00:00:00", 
      "pcPlayDurationPersonAvg": 0, 
      "formatPcPlayDurationPersonAvg": "00:00:00", 
      "mobilePlayDuration": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDurationVideoAvg": 0, 
      "formatMobilePlayDurationVideoAvg": "00:00:00", 
      "mobilePlayDurationPersonAvg": 0, 
      "formatMobilePlayDurationPersonAvg": "00:00:00"
    }
  ]
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
currentDay 日期
pcPlayDuration pc端播放时长,单位秒
formatPcPlayDuration 格式化的pc端播放时长
pcPlayDurationVideoAvg PC端视频平均播放时长,单位秒
formatPcPlayDurationVideoAvg 格式化的PC端视频平均播放时长
pcPlayDurationPersonAvg PC端人均播放时长,单位秒
formatPcPlayDurationPersonAvg 格式化的PC端人均播放时长
mobilePlayDuration 移动端播放时长,单位秒
formatMobilePlayDuration 格式化的移动端播放时长
mobilePlayDurationVideoAvg 移动端视频平均播放时长,单位秒
formatMobilePlayDurationVideoAvg 格式化后的移动端视频平均播放时长
mobilePlayDurationPersonAvg 移动端人均播放时长,单位秒
formatMobilePlayDurationPersonAvg 格式化的移动端人均播放时长

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$start="2018-07-03";
$end="2018-07-05";
$ptime=time()*1000;//13位
$secretkey="secretkey填写";
$str="end=".$end."&ptime=".$ptime."&start=".$start.$secretkey;

$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/play-duration/$userid?ptime=$ptime&sign=$hash&start=$start&end=$end";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询视频终端环境统计数据

接口URL

https://api.polyv.net/v2/device/{userid}

接口说明

查询视频终端环境统计数据,包括浏览器环境,操作系统环境,终端环境

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": {
    "device": [
      {
        "deviceName": "PC端", 
        "videoView": 52, 
        "formatPlayDuration": "00:28:18", 
        "playDuration": 1698, 
        "uniqueViewer": 20, 
        "percentage": "89.66"
      }, 
      {
        "deviceName": "移动端", 
        "videoView": 6, 
        "formatPlayDuration": "00:03:25", 
        "playDuration": 205, 
        "uniqueViewer": 5, 
        "percentage": "10.34"
      }
    ], 
    "operatingSystem": [
      {
        "operateSystemName": "Windows", 
        "videoView": 40, 
        "formatPlayDuration": "00:23:58", 
        "playDuration": 1438, 
        "uniqueViewer": 18, 
        "percentage": "68.97"
      }, 
      {
        "operateSystemName": "Linux", 
        "videoView": 12, 
        "formatPlayDuration": "00:04:20", 
        "playDuration": 260, 
        "uniqueViewer": 2, 
        "percentage": "20.69"
      }, 
      {
        "operateSystemName": "Android Mobile", 
        "videoView": 6, 
        "formatPlayDuration": "00:03:25", 
        "playDuration": 205, 
        "uniqueViewer": 5, 
        "percentage": "10.34"
      }
    ], 
    "browser": [
      {
        "browserName": "Chrome", 
        "formatPcPlayDuration": "00:28:18", 
        "pcPlayDuration": 1698, 
        "pcVideoView": 52, 
        "pcUniqueViewer": 20, 
        "formatMobilePlayDuration": "00:00:00", 
        "mobilePlayDuration": 0, 
        "mobileVideoView": 0, 
        "mobileUniqueViewer": 0, 
        "pcPercentage": "100.00", 
        "mobilePercentage": "0.00"
      }, 
      {
        "browserName": "微信", 
        "formatPcPlayDuration": "00:00:00", 
        "pcPlayDuration": 0, 
        "pcVideoView": 0, 
        "pcUniqueViewer": 0, 
        "formatMobilePlayDuration": "00:03:25", 
        "mobilePlayDuration": 205, 
        "mobileVideoView": 6, 
        "mobileUniqueViewer": 5, 
        "pcPercentage": "0.00", 
        "mobilePercentage": "100.00"
      }
    ]
  }
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
device 终端环境统计数据
operatingSystem 操作系统环境统计数据
browser 浏览器环境统计数据
deviceName 终端环境名称,PC端或移动端
operateSystemName 操作系统环境名称
browserName 浏览器环境名称
percentage 总占比
videoView 视频总播放量
uniqueViewer 视频总观众数
playDuration 视频总播放时长
pcPlayDuration PC端播放时长,单位秒formatP
formatPcPlayDuration 格式化的PC播放时长,00:00:00
pcVideoView PC端播放量
pcUniqueViewer PC端唯一观众数
pcPercentage PC端数据占比
mobilePlayDuration 移动端播放时长,单位秒
formatMobilePlayDuration 格式化的移动端播放时长,00:00:00
mobileVideoView 移动端播放量
mobileUniqueViewer 移动端播放量
mobilePercentage 移动端数据占比

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$start="2018-01-01";
$end="2018-07-06";
$ptime=time()*1000;//13位
$secretkey="secretKey";
$str="end=".$end."&ptime=".$ptime."&start=".$start.$secretkey;

$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/device/$userid?ptime=$ptime&sign=$hash&start=$start&end=$end";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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

查询视频播放时段统计数据

接口URL

https://api.polyv.net/v2/hourly/{userid}

接口说明

查询视频播放时段统计数据

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型及范围 说明
userid true string 用户id,路径参数
ptime true string 当前13位毫秒级时间戳,3分钟内有效
sign true string 签名,40位大写的sha1值
dr false string 时间段,具体值为以下几个:today(今天),yesterday(昨天),this_week(本周),last_week(上周),7days(最近7天),this_month(本月),last_month(上个月),this_year(今年),last_year(去年),默认值为7days
start false string 开始日期,格式为yyyy-MM-dd
end false string 结束日期,格式为yyyy-MM-dd

返回结果

{
  "code": 200, 
  "status": "success", 
  "message": "success", 
  "data": [
    {
      "currentHour": 0, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 1, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 2, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 3, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 4, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 5, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 6, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 7, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 8, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 9, 
      "formatPcPlayDuration": "00:12:11", 
      "pcPlayDuration": 731, 
      "pcFlowSize": 1503824, 
      "pcVideoView": 9, 
      "pcUniqueViewer": 5, 
      "formatMobilePlayDuration": "00:02:28", 
      "mobilePlayDuration": 148, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 2, 
      "mobileUniqueViewer": 2
    }, 
    {
      "currentHour": 10, 
      "formatPcPlayDuration": "00:00:25", 
      "pcPlayDuration": 25, 
      "pcFlowSize": 7048405, 
      "pcVideoView": 5, 
      "pcUniqueViewer": 5, 
      "formatMobilePlayDuration": "00:00:29", 
      "mobilePlayDuration": 29, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 2, 
      "mobileUniqueViewer": 2
    }, 
    {
      "currentHour": 11, 
      "formatPcPlayDuration": "00:02:08", 
      "pcPlayDuration": 128, 
      "pcFlowSize": 5549169, 
      "pcVideoView": 7, 
      "pcUniqueViewer": 6, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 12, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 13, 
      "formatPcPlayDuration": "00:00:14", 
      "pcPlayDuration": 14, 
      "pcFlowSize": 4640879, 
      "pcVideoView": 3, 
      "pcUniqueViewer": 2, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 14, 
      "formatPcPlayDuration": "00:02:53", 
      "pcPlayDuration": 173, 
      "pcFlowSize": 1633231, 
      "pcVideoView": 8, 
      "pcUniqueViewer": 4, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 15, 
      "formatPcPlayDuration": "00:01:24", 
      "pcPlayDuration": 84, 
      "pcFlowSize": 0, 
      "pcVideoView": 2, 
      "pcUniqueViewer": 2, 
      "formatMobilePlayDuration": "00:00:09", 
      "mobilePlayDuration": 9, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 1, 
      "mobileUniqueViewer": 1
    }, 
    {
      "currentHour": 16, 
      "formatPcPlayDuration": "00:00:34", 
      "pcPlayDuration": 34, 
      "pcFlowSize": 1461340, 
      "pcVideoView": 7, 
      "pcUniqueViewer": 2, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 17, 
      "formatPcPlayDuration": "00:02:12", 
      "pcPlayDuration": 132, 
      "pcFlowSize": 3809560, 
      "pcVideoView": 10, 
      "pcUniqueViewer": 4, 
      "formatMobilePlayDuration": "00:00:19", 
      "mobilePlayDuration": 19, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 1, 
      "mobileUniqueViewer": 1
    }, 
    {
      "currentHour": 18, 
      "formatPcPlayDuration": "00:06:17", 
      "pcPlayDuration": 377, 
      "pcFlowSize": 0, 
      "pcVideoView": 1, 
      "pcUniqueViewer": 1, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 19, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 20, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 21, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 22, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }, 
    {
      "currentHour": 23, 
      "formatPcPlayDuration": "00:00:00", 
      "pcPlayDuration": 0, 
      "pcFlowSize": 0, 
      "pcVideoView": 0, 
      "pcUniqueViewer": 0, 
      "formatMobilePlayDuration": "00:00:00", 
      "mobilePlayDuration": 0, 
      "mobileFlowSize": 0, 
      "mobileVideoView": 0, 
      "mobileUniqueViewer": 0
    }
  ]
}

失败返回json(不带jsonp)

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}

字段描述

字段名称 描述
currentHour 时段
pcPlayDuration pc播放时长,单位为秒
formatPcPlayDuration pc播放时长,格式为00:00:00
pcFlowSize pc消耗流量,单位为字节
pcVideoView pc端播放量
pcUniqueViewer pc端观众量
mobilePlayDuration 移动端播放时长,单位为秒
formatMobilePlayDuration 移动端播放时长,格式为00:00:00
mobileFlowSize 移动端消耗流量,单位为字节
mobileVideoView 移动端播放量
mobileUniqueViewer 移动端观众量

响应说明

错误代码 message 说明
400 sign can not be empty. 加密串为空
400 ptime is too old. 时间戳过期
400 ptime is illegal. 时间戳参数格式不对或者超过当前时间3分钟
400 Could not find user by userid. userid不存在
400 the sign is not right. 加密串不正确
401 start and end illegal. start日期大于end日期
500 query failed. 后台程序抛异常
200 success 提交成功

PHP请求示例

<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$dr="this_year";
$start="2018-01-01";
$end="2018-07-06";
$ptime=time()*1000;//13位
$secretkey="填写secretkey";
$str="end=".$end."&ptime=".$ptime."&start=".$start.$secretkey;

$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/hourly/$userid?ptime=$ptime&sign=$hash&start=$start&end=$end";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

签名规则:

将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:

1、请求参数为

ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"

2、将请求参数按照参数名字典顺序排列

format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"

3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:

format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z

4、生成签名sign

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