获取API实例
原创
©著作权归作者所有:来自51CTO博客作者Q神的原创作品,请联系作者获取转载授权,否则将追究法律责任
获取频道某段时间的直播统计数据
官方文档:http://dev.polyv.net/2017/liveproduct/l-api/hqzbxx/summary/
<?php
//生成sign
//生成sign 签名生成规则
//$sign = getSign($params); //详细查看config.php文件的getSign方法
// 1. 对加密数组进行字典排序
//签名验证必需参数
$appId = "ez00000000v0";
$timestamp = time()*1000;
$appSecret = "5ebb000000000005d1";
//接口需要的参数(非sign)赋值
$userId = "ae00005";
$channelId = "10004";
$startDay = "2018-04-03";
$endDay = "2018-04-03";
$params = array(
'appId'=>$appId,
'endDay'=>$endDay,
'startDay'=>$startDay,
'timestamp'=>$timestamp
);
// 1. 对加密数组进行字典排序
foreach ($params as $key=>$value){
$arr[$key] = $key;
}
sort($arr);
$str = $appSecret;
foreach ($arr as $k => $v) {
$str = $str.$arr[$k].$params[$v];
}
$restr = $str.$appSecret;
$sign = strtoupper(md5($restr));
//接口请求url
$url = "http://api.live.polyv.net/v2/statistics/".$channelId."/summary?timestamp=".$timestamp."&sign=".$sign."&endDay=".$endDay."&startDay=".$startDay."&appId=".$appId;
//输出接口请求结果
echo file_get_contents($url);
?>
<meta charset="utf-8">