domain=$config['domain']; $this->config=$config; $this->siteId=$config['siteId']; } /** * 获取数据 * @param string $method 查询方法 * @param string $mertics 查询参数 * @param string $order 排序 */ private function getData($param) { $reportService = new ReportService($this->config); // $reportService = new ReportService(API_URL, USERNAME,TOKEN,PASSWORD); if(!$this->siteId){ return false; // $ret = $reportService->getSiteList(); // $siteList = $ret['body']['data'][0]['list']; // if($siteList){ // if (count($siteList) > 0) { // if($this->domain){ // foreach ($siteList as $key => $value) { // if($this->domain==$value["domain"]){ // $this->siteId=$value["site_id"]; // break; // }else{ // continue; // } // } // if(!$this->siteId){ // $this->siteId = $siteList[0]['site_id']; // } // }else{ // $this->siteId = $siteList[0]['site_id']; // } // }else{ // return false; // } // }else{ // return false; // } } $param['site_id']=$this->siteId; $res = $reportService->getData($param); if(ACCOUNT_TYPE==3){ return $res; }else{ return json_decode($res['raw'],true); } } public function getSiteList(){ // $reportService = new ReportService(API_URL, USERNAME,TOKEN,PASSWORD); $reportService = new ReportService($this->config); $ret = $reportService->getSiteList(); if(ACCOUNT_TYPE==3){ $siteList = $ret['list']; }else{ $siteList = $ret['body']['data'][0]['list']; } $data=[]; if($siteList){ foreach ($siteList as $key => $value) { $data[]=[ 'site_id'=>$value["site_id"], 'domain'=>$value["domain"] ]; } } return $data; } /** * 获取网站今日流量与昨日对比 */ public function getOutline() { $param=[ 'method' => 'overview/getOutline', ]; return $this->getData($param); } /** * 获取今日趋势分析数据 */ public function trendTimeA() { $param=[ 'method' => 'trend/time/a', 'metrics' => 'pv_count,visitor_count',//,ip_count,bounce_ratio,avg_visit_time 'start_date'=> date("Ymd"), 'end_date' => date("Ymd"), 'order' => 'simple_date_title,asc' ]; $res=$this->getData($param); return $res; } /** * [getTimeTrendRpt 网站概况] * @return [type] [description] */ public function getTimeTrendRpt($start_date,$end_date){ $param=[ 'method' => 'overview/getTimeTrendRpt', 'metrics' => 'pv_count,visitor_count', 'start_date' => $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * 获取访问地域分布数据 */ public function getDistrictRpt($start_date,$end_date) { $param=[ 'method'=>'overview/getDistrictRpt', 'metrics'=>'pv_count,visitor_count', 'start_date'=> $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * 获取访问搜索词、来源网站、入口界面、受访页面、新老访客数据 */ public function getCommonTrackRpt($start_date,$end_date) { $param=[ 'method'=>'overview/getCommonTrackRpt', 'metrics'=>'pv_count', 'start_date'=> $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * 实时访客 * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @return [array] [description] */ public function trendLatestA($page,$max_results){ $start_index=($page-1)*$max_results; $param=[ 'method' => 'trend/latest/a', 'metrics' => 'start_time,area,source,access_page,keyword,searchword,ip,visit_time,visit_pages', 'max_results' => $max_results, 'start_index' => $start_index ]; return $this->getData($param); } /** * [sourceAll 全部来源] * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @param [date] $start_date [开始时间] * @param [date] $end_date [结束时间] * @return [array] [description] */ public function sourceAll($page,$max_results,$start_date,$end_date){ $start_index=($page-1)*$max_results; $param=[ 'method' => 'source/all/a', 'metrics' => 'pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time', 'viewType' => 'site', 'max_results' => $max_results, 'start_index' => $start_index, 'start_date' => $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * [sourceSearchword 搜索词] * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @param [date] $start_date [开始时间] * @param [date] $end_date [结束时间] * @return [array] [description] */ public function sourceSearchword($page,$max_results,$start_date,$end_date){ $start_index=($page-1)*$max_results; $param=[ 'method' => 'source/searchword/a', 'metrics' => 'pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time', 'viewType' => 'site', 'max_results' => $max_results, 'start_index' => $start_index, 'start_date' => $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * [visitToppage 受访页面] * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @param [date] $start_date [开始时间] * @param [date] $end_date [结束时间] * @return [array] [description] */ public function visitToppage($page,$max_results,$start_date,$end_date){ $start_index=($page-1)*$max_results; $param=[ 'method' => 'visit/toppage/a', 'metrics' => 'pv_count,visitor_count,ip_count,visit1_count,outward_count,exit_count,exit_ratio,average_stay_time', 'max_results' => $max_results, 'start_index' => $start_index, 'start_date' => $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } /** * [visitDistrict 地域分布(按省)] * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @param [date] $start_date [开始时间] * @param [date] $end_date [结束时间] * @return [array] [description] */ public function visitDistrict($param){ $param['method']='visit/district/a'; return $this->getData($param); } /** * [visitDistrictTop 地域分布(按城市)] * @param [type] $start_date [开始时间] * @param [type] $end_date [结束时间] * @param [type] $area [省份] * @return [type] [description] */ public function visitDistrictTop($start_date,$end_date,$area){ $param=[ 'method' => 'visit/district/top', 'metrics' => 'pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time', 'start_date' => $start_date, 'end_date' => $end_date, 'viewType' => 'city', 'area' => $area ]; return $this->getData($param); } /** * [visitWorld 地域分布(按国家)] * @param [int] $page [页码] * @param [int] $max_results [每页数量] * @param [date] $start_date [开始时间] * @param [date] $end_date [结束时间] * @return [array] [description] */ public function visitWorld($start_date,$end_date){ $param=[ 'method' => 'visit/world/a', 'metrics' => 'pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time', 'start_date' => $start_date, 'end_date' => $end_date, ]; return $this->getData($param); } public function rankGetData($start_date,$end_date){ $param=[ 'method' => 'opt/searchwordrank/getData', 'metrics' => '', 'start_date' => $start_date, 'end_date' => $end_date, 'viewType' => 'searchword_rank' ]; return $this->getData($param); } public function rankGetWords(){ $param=[ 'method' => 'opt/searchwordrank/getWords', ]; return $this->getData($param); } public function rankSetWords($words){ $param=[ 'method' => 'opt/searchwordrank/setWords', 'words' => $words ]; return $this->getData($param); } public function reportSend($param){ $param['method'] = 'home/reportsend/add'; return $this->getData($param); } }