From 7a5770cef4eed1bb86741ac3e2a90a3cb038ade2 Mon Sep 17 00:00:00 2001 From: rexshi Date: Wed, 15 Aug 2018 14:18:19 +0800 Subject: [PATCH] Add cdn loganalyze API --- examples/cdn_get_loganalyze_bandwidth.php | 24 ++ examples/cdn_get_loganalyze_hitmiss.php | 24 ++ examples/cdn_get_loganalyze_ispreqcount.php | 24 ++ examples/cdn_get_loganalyze_isptraffic.php | 24 ++ examples/cdn_get_loganalyze_pageview.php | 24 ++ examples/cdn_get_loganalyze_reqcount.php | 24 ++ examples/cdn_get_loganalyze_statuscode.php | 24 ++ examples/cdn_get_loganalyze_topcountip.php | 24 ++ examples/cdn_get_loganalyze_topcounturl.php | 24 ++ examples/cdn_get_loganalyze_toptrafficip.php | 24 ++ examples/cdn_get_loganalyze_toptrafficurl.php | 24 ++ examples/cdn_get_loganalyze_traffic.php | 24 ++ examples/cdn_get_loganalyze_uniquevisitor.php | 24 ++ src/Qiniu/Cdn/CdnManager.php | 311 ++++++++++++++++++ 14 files changed, 623 insertions(+) create mode 100644 examples/cdn_get_loganalyze_bandwidth.php create mode 100644 examples/cdn_get_loganalyze_hitmiss.php create mode 100644 examples/cdn_get_loganalyze_ispreqcount.php create mode 100644 examples/cdn_get_loganalyze_isptraffic.php create mode 100644 examples/cdn_get_loganalyze_pageview.php create mode 100644 examples/cdn_get_loganalyze_reqcount.php create mode 100644 examples/cdn_get_loganalyze_statuscode.php create mode 100644 examples/cdn_get_loganalyze_topcountip.php create mode 100644 examples/cdn_get_loganalyze_topcounturl.php create mode 100644 examples/cdn_get_loganalyze_toptrafficip.php create mode 100644 examples/cdn_get_loganalyze_toptrafficurl.php create mode 100644 examples/cdn_get_loganalyze_traffic.php create mode 100644 examples/cdn_get_loganalyze_uniquevisitor.php diff --git a/examples/cdn_get_loganalyze_bandwidth.php b/examples/cdn_get_loganalyze_bandwidth.php new file mode 100644 index 00000000..ee5784e3 --- /dev/null +++ b/examples/cdn_get_loganalyze_bandwidth.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeBandwidth($domains, '1day', array('global'), 'all', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_hitmiss.php b/examples/cdn_get_loganalyze_hitmiss.php new file mode 100644 index 00000000..5b468645 --- /dev/null +++ b/examples/cdn_get_loganalyze_hitmiss.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeHitmiss($domains, '1hour', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_ispreqcount.php b/examples/cdn_get_loganalyze_ispreqcount.php new file mode 100644 index 00000000..db3c2c85 --- /dev/null +++ b/examples/cdn_get_loganalyze_ispreqcount.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeIspreqcount($domains, '1hour', 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_isptraffic.php b/examples/cdn_get_loganalyze_isptraffic.php new file mode 100644 index 00000000..613e432c --- /dev/null +++ b/examples/cdn_get_loganalyze_isptraffic.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeIsptraffic($domains, array('china', 'oversea'), '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_pageview.php b/examples/cdn_get_loganalyze_pageview.php new file mode 100644 index 00000000..fae82c80 --- /dev/null +++ b/examples/cdn_get_loganalyze_pageview.php @@ -0,0 +1,24 @@ +getCdnLoganalyzePageview($domains, '1day', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_reqcount.php b/examples/cdn_get_loganalyze_reqcount.php new file mode 100644 index 00000000..4efb2d8b --- /dev/null +++ b/examples/cdn_get_loganalyze_reqcount.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeReqcount($domains, '1hour', 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_statuscode.php b/examples/cdn_get_loganalyze_statuscode.php new file mode 100644 index 00000000..8fea79f5 --- /dev/null +++ b/examples/cdn_get_loganalyze_statuscode.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeStatuscode($domains, '1hour', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_topcountip.php b/examples/cdn_get_loganalyze_topcountip.php new file mode 100644 index 00000000..e360608e --- /dev/null +++ b/examples/cdn_get_loganalyze_topcountip.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeTopcountip($domains, 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_topcounturl.php b/examples/cdn_get_loganalyze_topcounturl.php new file mode 100644 index 00000000..ccd83e15 --- /dev/null +++ b/examples/cdn_get_loganalyze_topcounturl.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeTopcounturl($domains, 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_toptrafficip.php b/examples/cdn_get_loganalyze_toptrafficip.php new file mode 100644 index 00000000..1522e356 --- /dev/null +++ b/examples/cdn_get_loganalyze_toptrafficip.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeToptrafficip($domains, 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_toptrafficurl.php b/examples/cdn_get_loganalyze_toptrafficurl.php new file mode 100644 index 00000000..f1c46108 --- /dev/null +++ b/examples/cdn_get_loganalyze_toptrafficurl.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeToptrafficurl($domains, 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_traffic.php b/examples/cdn_get_loganalyze_traffic.php new file mode 100644 index 00000000..f058af19 --- /dev/null +++ b/examples/cdn_get_loganalyze_traffic.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeTraffic($domains, '1day', array('global'), 'all', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/examples/cdn_get_loganalyze_uniquevisitor.php b/examples/cdn_get_loganalyze_uniquevisitor.php new file mode 100644 index 00000000..579d1278 --- /dev/null +++ b/examples/cdn_get_loganalyze_uniquevisitor.php @@ -0,0 +1,24 @@ +getCdnLoganalyzeUniquevisitor($domains, 'global', '2018-08-01', '2018-08-03'); +if ($getLogErr != null) { + var_dump($getLogErr); +} else { + echo "get cdn log analyze top count url success\n"; + print_r($logListData); +} diff --git a/src/Qiniu/Cdn/CdnManager.php b/src/Qiniu/Cdn/CdnManager.php index a460ec2d..cd6e72fc 100644 --- a/src/Qiniu/Cdn/CdnManager.php +++ b/src/Qiniu/Cdn/CdnManager.php @@ -146,6 +146,317 @@ public function getCdnLogList(array $domains, $logDate) return $this->post($url, $body); } + /** + * @param array $domains 待获取区域运营商流量的域名数组 + * @param string $freq 待获取区域运营商流量的粒度,可选项为 5min、1hour、1day + * @param array $regions 待获取区域运营商流量的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param array $isp 待获取区域运营商流量的ISP运营商,例如比如all(所有 ISP),telecom(电信),unicom(联通),mobile(中国移动),drpeng(鹏博士),tietong(铁通),cernet(教育网) + * @param string $startDate 待获取区域运营商流量的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取区域运营商流量的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeTraffic(array $domains, $freq, $regions, $isp, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['regions'] = $regions; + $req['isp'] = $isp; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/traffic'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取区域运营商带宽的域名数组 + * @param string $freq 待获取区域运营商带宽的粒度,可选项为 5min、1hour、1day + * @param array $regions 待获取区域运营商带宽的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param array $isp 待获取区域运营商带宽的ISP运营商,例如比如all(所有 ISP),telecom(电信),unicom(联通),mobile(中国移动),drpeng(鹏博士),tietong(铁通),cernet(教育网) + * @param string $startDate 待获取区域运营商带宽的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取区域运营商带宽的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeBandwidth(array $domains, $freq, $regions, $isp, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['regions'] = $regions; + $req['isp'] = $isp; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/bandwidth'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取状态码数据的域名数组 + * @param string $freq 待获取状态码数据的粒度,可选项为 5min、1hour、1day + * @param string $startDate 待获取状态码数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取状态码数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeStatuscode(array $domains, $freq, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/statuscode'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取命中率数据的域名数组 + * @param string $freq 待获取命中率数据的粒度,可选项为 5min、1hour、1day + * @param string $startDate 待获取命中率数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取命中率数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeHitmiss(array $domains, $freq, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/hitmiss'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取请求次数数据的域名数组 + * @param string $freq 待获取请求次数数据的粒度,可选项为 5min、1hour、1day + * @param string $region 待获取请求次数数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取请求次数数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取请求次数数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeReqcount(array $domains, $freq, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/reqcount'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取 ISP 请求次数数据的域名数组 + * @param string $freq 待获取 ISP 请求次数数据的粒度,可选项为 5min、1hour、1day + * @param string $region 待获取 ISP 请求次数数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取 ISP 请求次数数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取 ISP 请求次数数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeIspreqcount(array $domains, $freq, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/ispreqcount'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取 ISP 流量占比数据的域名数组 + * @param array $regions 待获取 ISP 流量占比数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取 ISP 流量占比数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取 ISP 流量占比数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeIsptraffic(array $domains, $regions, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['regions'] = $regions; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/isptraffic'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取访问量数据的域名数组 + * @param string $region 待获取访问量数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取访问量数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取访问量数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeTopcountip(array $domains, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/topcountip'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取访问量数据的域名数组 + * @param string $region 待获取访问量数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取访问量数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取访问量数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeToptrafficip(array $domains, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/toptrafficip'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取访问量数据的域名数组 + * @param string $region 待获取访问量数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取访问量数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取访问量数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeTopcounturl(array $domains, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/topcounturl'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取访问量数据的域名数组 + * @param string $region 待获取访问量数据的区域,例如global,具体看参考:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#region + * @param string $startDate 待获取访问量数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取访问量数据的结束日期,格式类似 2017-01-01 + * + * @return array 错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeToptrafficurl(array $domains, $region, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['region'] = $region; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/toptrafficurl'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取PageView数据的域名数组 + * @param string $freq 待获取PageView数据的粒度,可选项为 1hour、1day + * @param string $startDate 待获取PageView数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取PageView数据的结束日期,格式类似 2017-01-01 + * + * @return array 获取PageView数据时的错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzePageview(array $domains, $freq, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/pageview'; + $body = json_encode($req); + return $this->post($url, $body); + } + + /** + * @param array $domains 待获取UniqueVisitor数据的域名数组 + * @param string $freq 待获取UniqueVisitor数据的粒度,可选项为 1hour、1day + * @param string $startDate 待获取UniqueVisitor数据的开始日期,格式类似 2017-01-01 + * @param string $endDate 待获取UniqueVisitor数据的结束日期,格式类似 2017-01-01 + * + * @return array 获取UniqueVisitor数据时的错误信息,参考 examples/cdn_manager.php 代码 + * + * @link https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis + */ + public function getCdnLoganalyzeUniquevisitor(array $domains, $freq, $startDate, $endDate) + { + $req = array(); + $req['domains'] = $domains; + $req['freq'] = $freq; + $req['startDate'] = $startDate; + $req['endDate'] = $endDate; + + $url = $this->server . '/v2/tune/loganalyze/uniquevisitor'; + $body = json_encode($req); + return $this->post($url, $body); + } + private function post($url, $body) { $headers = $this->auth->authorization($url, $body, 'application/json');