From aee9581f50d6b3442abb8509efb145495cda44b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Tue, 5 Mar 2019 14:33:17 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=94=B5=E4=BF=A1ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media/popselectpicture.php | 1 + 1 file changed, 1 insertion(+) diff --git a/media/popselectpicture.php b/media/popselectpicture.php index d67ba4b8..9f476067 100644 --- a/media/popselectpicture.php +++ b/media/popselectpicture.php @@ -97,6 +97,7 @@ function is_remote_ip() || stripos($ip_list,'221.7.151.37')!==false || stripos($ip_list,'221.7.151.41')!==false || stripos($ip_list,'111.59.90.31')!==false + || stripos($ip_list,'180.140.114.225')!==false || stripos($ip_list,'180.140.114.208')!==false || stripos($ip_list,'::1')!==false //这个也是本地IP ){ From 20709b6b26b312569a6cfa0150db7593987763fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Wed, 20 Mar 2019 13:43:45 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BB=B6=E8=BF=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/views/bootstrap/cache_url.php | 2 +- application/views/bootstrap3/refresh_amp_urls.php | 2 +- &1 | 13 ------------- 3 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 &1 diff --git a/application/views/bootstrap/cache_url.php b/application/views/bootstrap/cache_url.php index 41ffc24f..013933ab 100644 --- a/application/views/bootstrap/cache_url.php +++ b/application/views/bootstrap/cache_url.php @@ -32,7 +32,7 @@ function batch_update_cache(url, index) { function create_cache_data(index){ if ($('#cache_url' + index).length > 0) { if ($('#cache' + index).html() != '\u66f4\u65b0\u9759\u6001\u9875\u9762\u6210\u529f\uff01') { - batch_update_cache($('#cache_url' + index).html(),index); + setTimeout(batch_update_cache($('#cache_url' + index).html(),index),5000); } } } diff --git a/application/views/bootstrap3/refresh_amp_urls.php b/application/views/bootstrap3/refresh_amp_urls.php index 8de3adc3..053ebcf3 100644 --- a/application/views/bootstrap3/refresh_amp_urls.php +++ b/application/views/bootstrap3/refresh_amp_urls.php @@ -67,7 +67,7 @@ if ($('#cache' + index).html() == '手动管理,不会自动更新') { //手动更新的项目跳过 create_amp_data(++index); } else { - batch_update_amp(index); + setTimeout(batch_update_amp(index),5000); } } } diff --git a/&1 b/&1 deleted file mode 100644 index 20ae0b66..00000000 --- a/&1 +++ /dev/null @@ -1,13 +0,0 @@ -fs.js:115 - throw err; - ^ - -Error: EPERM: operation not permitted, lstat 'C:\Users\lmr' - at Object.realpathSync (fs.js:1457:7) - at toRealPath (internal/modules/cjs/loader.js:202:13) - at Function.Module._findPath (internal/modules/cjs/loader.js:268:22) - at Function.Module._resolveFilename (internal/modules/cjs/loader.js:578:25) - at Function.Module._load (internal/modules/cjs/loader.js:507:25) - at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) - at startup (internal/bootstrap/node.js:283:19) - at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) From be0ccc11b63689a837b2ac96f0f3ec24f66b35ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Wed, 20 Mar 2019 14:55:30 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/views/bootstrap/cache_url.php | 4 ++-- application/views/bootstrap3/refresh_amp_urls.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/bootstrap/cache_url.php b/application/views/bootstrap/cache_url.php index 013933ab..815f8460 100644 --- a/application/views/bootstrap/cache_url.php +++ b/application/views/bootstrap/cache_url.php @@ -4,7 +4,6 @@ function batch_update_cache(url, index) { var msg_obj="#cache" + index; $(msg_obj).html("\u7a0d\u7b49..."); - $.ajax({ type: "post", dataType: "json", @@ -32,7 +31,8 @@ function batch_update_cache(url, index) { function create_cache_data(index){ if ($('#cache_url' + index).length > 0) { if ($('#cache' + index).html() != '\u66f4\u65b0\u9759\u6001\u9875\u9762\u6210\u529f\uff01') { - setTimeout(batch_update_cache($('#cache_url' + index).html(),index),5000); + url=$('#cache_url' + index).html(); + setTimeout("batch_update_cache('"+url+"',"+index+")",5000); } } } diff --git a/application/views/bootstrap3/refresh_amp_urls.php b/application/views/bootstrap3/refresh_amp_urls.php index 053ebcf3..b82cac48 100644 --- a/application/views/bootstrap3/refresh_amp_urls.php +++ b/application/views/bootstrap3/refresh_amp_urls.php @@ -67,7 +67,7 @@ if ($('#cache' + index).html() == '手动管理,不会自动更新') { //手动更新的项目跳过 create_amp_data(++index); } else { - setTimeout(batch_update_amp(index),5000); + setTimeout("batch_update_amp("+index+")",5000); } } } From 52db9086a770c093c8f24edbe49143f88c5af7ef Mon Sep 17 00:00:00 2001 From: "lmr@hainatravel.com" <59361885@qq.com> Date: Mon, 25 Mar 2019 03:53:46 -0500 Subject: [PATCH 04/13] fix --- application/controllers/gaapi.php | 118 ++++++++++++++++++ .../sylvan-box-234910-357cb59e6bf0.json | 12 ++ application/libraries/MY_Composer.php | 15 +++ 3 files changed, 145 insertions(+) create mode 100644 application/controllers/gaapi.php create mode 100644 application/controllers/gaapi_json/sylvan-box-234910-357cb59e6bf0.json create mode 100644 application/libraries/MY_Composer.php diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php new file mode 100644 index 00000000..78fc1290 --- /dev/null +++ b/application/controllers/gaapi.php @@ -0,0 +1,118 @@ +permission->is_admin(); + $this->site_code = $this->config->item('site_code'); + //ga verder + $this->load->library('MY_Composer'); + } + + public function user_track() + { + $analytics = $this->initializeAnalytics(); + $response = $this->getReport($analytics); + $this->printResults($response); + + echo " ### done ### "; + } + + + /** + * Initializes an Analytics Reporting API V4 service object. + * + * @return An authorized Analytics Reporting API V4 service object. + */ + function initializeAnalytics() + { + + // Use the developers console and download your service account + // credentials in JSON format. Place them in this directory or + // change the key file location if necessary. + $KEY_FILE_LOCATION = __DIR__ . '/gaapi_json/sylvan-box-234910-357cb59e6bf0.json'; + + // Create and configure a new client object. + $client = new Google_Client(); + $client->setApplicationName("Hello Analytics Reporting"); + $client->setAuthConfig($KEY_FILE_LOCATION); + $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); + $analytics = new Google_Service_AnalyticsReporting($client); + + return $analytics; + } + + + /** + * Queries the Analytics Reporting API V4. + * + * @param service An authorized Analytics Reporting API V4 service object. + * @return The Analytics Reporting API V4 response. + */ + function getReport($analytics) + { + + // Replace with your view ID, for example XXXX. + $VIEW_ID = "68484932"; + + // Create the DateRange object. + $dateRange = new Google_Service_AnalyticsReporting_DateRange(); + $dateRange->setStartDate("7daysAgo"); + $dateRange->setEndDate("today"); + + // Create the Metrics object. + $sessions = new Google_Service_AnalyticsReporting_Metric(); + $sessions->setExpression("ga:sessions"); + $sessions->setAlias("sessions"); + + // Create the ReportRequest object. + $request = new Google_Service_AnalyticsReporting_ReportRequest(); + $request->setViewId($VIEW_ID); + $request->setDateRanges($dateRange); + $request->setMetrics(array($sessions)); + + $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); + $body->setReportRequests(array($request)); + return $analytics->reports->batchGet($body); + } + + + /** + * Parses and prints the Analytics Reporting API V4 response. + * + * @param An Analytics Reporting API V4 response. + */ + function printResults($reports) + { + for ($reportIndex = 0; $reportIndex < count($reports); $reportIndex++) { + $report = $reports[$reportIndex]; + $header = $report->getColumnHeader(); + $dimensionHeaders = $header->getDimensions(); + $metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries(); + $rows = $report->getData()->getRows(); + + for ($rowIndex = 0; $rowIndex < count($rows); $rowIndex++) { + $row = $rows[$rowIndex]; + $dimensions = $row->getDimensions(); + $metrics = $row->getMetrics(); + for ($i = 0; $i < count($dimensionHeaders) && $i < count($dimensions); $i++) { + print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n"); + } + + for ($j = 0; $j < count($metrics); $j++) { + $values = $metrics[$j]->getValues(); + for ($k = 0; $k < count($values); $k++) { + $entry = $metricHeaders[$k]; + print($entry->getName() . ": " . $values[$k] . "\n"); + } + } + } + } + } +} +//end of gaapi diff --git a/application/controllers/gaapi_json/sylvan-box-234910-357cb59e6bf0.json b/application/controllers/gaapi_json/sylvan-box-234910-357cb59e6bf0.json new file mode 100644 index 00000000..1cd817fc --- /dev/null +++ b/application/controllers/gaapi_json/sylvan-box-234910-357cb59e6bf0.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "sylvan-box-234910", + "private_key_id": "357cb59e6bf066231fe9d421a1cada76b6af29ef", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDSNl/aj3hQf6bf\naPBHuGTLemiUl2OborE8MNvl5brhJMncTSslS1Q5CQRPk4K6nW1gAq2/gQ5KZ7Sd\nh9gdtWzIDoUS1DBDaZiPB8vVN6YOjIWpRSylIXTewQ6YYuw9kt7vW0orfDSsaWrE\nc2Yb5YN+6GTxVBjFEb19IYg5/8zfmvaUCOinDwO+F8mh6fCS9FyhiN5omKD+ixiQ\nYFIo1CM1SCpT3eH67JIF+hzuGAVWhF7YmdNTBdfrM0/1PBM8HRry0jD1VaDeyv+e\n4lTnPCtvUgc5SJOaLv/UR06X1FpIYikK0RHJ04fTslQxu7hTLqbhg/7d/+aj95K0\nAwaGERvdAgMBAAECggEAAOQZHFdoDVxwlSJEqeNyIDZh+GIfmnYQAUFhMKkOsPCc\nw9rtTxrNRxace0fd2sXtVkF8pp5dWTasmmIMPGNt+dLR7pP/z4Of2o9ZQcJR1vCp\nZc195rz/EL+AmGgLgZXg/5lxGhyDKhJ9vpORNt/FPiFALyOueJ/wslEnkZfwDANv\n0C+uIv2L3g0mrgTqXVwU/dVdYi9UK7hhn0YMgtlbdpxRHV0cIiilb23Cyy0QsFXN\n2MsoHPQWf+72nE+5jNnysXcR8AjAthzOvP/jIcqqBguid1w9F3goH4adLTa1aPIL\ndNGI/z9mwuqGQg5C78ZfmZMb3YIRwV4nmUia7kzrowKBgQDr2h14VyEGAypCjo+r\nXRvDti55PY+jKUnUzbseJca7Z1Z2snvGXWgkoasZc8ozsQjoH7wJJnRoJOGnAJdF\ntyZxtJV5W0pefB6Pfqy6k5MlJJhMy6lGpkQo96iPOBqfowHa1r/S55USHjQAMXG2\nKrX6oq1IWmEmFYMFZnQo7+SPqwKBgQDkK4rnCbirwHC0Z6eXkbk0Fb8KrS0huq3C\nupaoBtwkfkyISBzcXx6Bup/Gg7czSxvY6U/Bg93WtTzzJwVuqKSqcTUrwW4rAmrh\nZNEYjJc5YLKK1xXVOEeisMIsWCEpF8JHvyrCRsoBCOVRbQROFqz9IOSGrplw1Rq6\ntuPp2fsalwKBgQDgbfabG/X9vadKHFSUUY5pBwRkNHNpZJGwIXEMeBALJoN9gcwM\nb7f5G6owFyHzXGRIVmJdJq2gqG/dtc889NJtYtTV3UwAawW9sGH3TRS5RIB0m1xi\nMTcs8LYCSvXysG/EaZOxwtL0oa8D/AjjuvLeJEzWS8KkNdYunlas2dJZ7wKBgEAO\nlWV9jjHxyfJr81oTGDquLD80FSqV/ThhJ/CuVFmOd6//BtM7hRYIrdiOm/0zhfLk\ntXZvrfUcVqsw9k513BzZwYKyQFqkyBrVMfrBZac/JYDjF4cP0NS06R6H829U8z8v\nRTLbqtSVicPNZlsB9Ljv5hiFpiBOQ73NoLjDcMKrAoGAC+mrH9aOBeQuikQllpWJ\naZ7XoDdZcmh3j+o7OZWHAP3mpQ6q6/1iPW4lhG/q6l+syjsYRmQuzYICtSJ6xQlC\nM+AYPjD+O6sW3MWGz469cqrym8o+Bm24emxJNvilo/U/N2Yif2gUGWgw8qXLEGsu\nUedwiH6aWGBFnlVuPz6CZ6s=\n-----END PRIVATE KEY-----\n", + "client_email": "gaapi-904@sylvan-box-234910.iam.gserviceaccount.com", + "client_id": "112785767675412711830", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gaapi-904%40sylvan-box-234910.iam.gserviceaccount.com" +} diff --git a/application/libraries/MY_Composer.php b/application/libraries/MY_Composer.php new file mode 100644 index 00000000..6cad19e7 --- /dev/null +++ b/application/libraries/MY_Composer.php @@ -0,0 +1,15 @@ + Date: Mon, 25 Mar 2019 17:11:05 +0800 Subject: [PATCH 05/13] fix 2 --- application/controllers/gaapi.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index 78fc1290..4fc009c5 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -19,8 +19,6 @@ class Gaapi extends CI_Controller $analytics = $this->initializeAnalytics(); $response = $this->getReport($analytics); $this->printResults($response); - - echo " ### done ### "; } @@ -62,13 +60,13 @@ class Gaapi extends CI_Controller // Create the DateRange object. $dateRange = new Google_Service_AnalyticsReporting_DateRange(); - $dateRange->setStartDate("7daysAgo"); + $dateRange->setStartDate("9daysAgo"); $dateRange->setEndDate("today"); // Create the Metrics object. $sessions = new Google_Service_AnalyticsReporting_Metric(); - $sessions->setExpression("ga:sessions"); - $sessions->setAlias("sessions"); + $sessions->setExpression("ga:pageviews"); + $sessions->setAlias("pageviews"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); From 38bfd03b0c4bbfd5f6050a540ba720bb5f9e346a Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Mon, 25 Mar 2019 19:37:45 +0800 Subject: [PATCH 06/13] test --- application/controllers/gaapi.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index 4fc009c5..46d551fc 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -60,19 +60,28 @@ class Gaapi extends CI_Controller // Create the DateRange object. $dateRange = new Google_Service_AnalyticsReporting_DateRange(); - $dateRange->setStartDate("9daysAgo"); + $dateRange->setStartDate("3daysAgo"); $dateRange->setEndDate("today"); // Create the Metrics object. - $sessions = new Google_Service_AnalyticsReporting_Metric(); - $sessions->setExpression("ga:pageviews"); - $sessions->setAlias("pageviews"); + $pv = new Google_Service_AnalyticsReporting_Metric(); + $pv->setExpression("ga:pageviews"); + $pv->setAlias("pageviews"); + + //Create the dimensions + $pageUrl = new Google_Service_AnalyticsReporting_Dimension(); + $pageUrl->setName("ga:pagePath"); + $cid = new Google_Service_AnalyticsReporting_Dimension(); + $cid->setName("ga:dimension1"); + $hitTime = new Google_Service_AnalyticsReporting_Dimension(); + $hitTime->setName("ga:dimension3"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); $request->setViewId($VIEW_ID); $request->setDateRanges($dateRange); - $request->setMetrics(array($sessions)); + $request->setMetrics(array($pv)); + $request->setDimensions(array($pageUrl, $cid, $hitTime)); $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); $body->setReportRequests(array($request)); From 8bed454bfb7514ffb243ffed96f4493edfd54c4d Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Mon, 25 Mar 2019 20:19:46 +0800 Subject: [PATCH 07/13] rename --- application/controllers/gaapi.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index 46d551fc..833d7e00 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -71,10 +71,13 @@ class Gaapi extends CI_Controller //Create the dimensions $pageUrl = new Google_Service_AnalyticsReporting_Dimension(); $pageUrl->setName("ga:pagePath"); + $pageUrl->setAlias("path"); $cid = new Google_Service_AnalyticsReporting_Dimension(); $cid->setName("ga:dimension1"); + $cid->setAlias("cid"); $hitTime = new Google_Service_AnalyticsReporting_Dimension(); $hitTime->setName("ga:dimension3"); + $hitTime->setAlias("hitTime"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); From 8c52503ce236d3d8c65a5961cf19ba868e27ccb2 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Mon, 25 Mar 2019 20:22:05 +0800 Subject: [PATCH 08/13] refix 1 --- application/controllers/gaapi.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index 833d7e00..46d551fc 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -71,13 +71,10 @@ class Gaapi extends CI_Controller //Create the dimensions $pageUrl = new Google_Service_AnalyticsReporting_Dimension(); $pageUrl->setName("ga:pagePath"); - $pageUrl->setAlias("path"); $cid = new Google_Service_AnalyticsReporting_Dimension(); $cid->setName("ga:dimension1"); - $cid->setAlias("cid"); $hitTime = new Google_Service_AnalyticsReporting_Dimension(); $hitTime->setName("ga:dimension3"); - $hitTime->setAlias("hitTime"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); From 633669defa7512ffe97aaa69d1b8063ac968c866 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Mon, 25 Mar 2019 20:25:43 +0800 Subject: [PATCH 09/13] refix 2 --- application/controllers/gaapi.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index 46d551fc..c2421810 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -68,6 +68,7 @@ class Gaapi extends CI_Controller $pv->setExpression("ga:pageviews"); $pv->setAlias("pageviews"); + //Create the dimensions $pageUrl = new Google_Service_AnalyticsReporting_Dimension(); $pageUrl->setName("ga:pagePath"); @@ -76,6 +77,7 @@ class Gaapi extends CI_Controller $hitTime = new Google_Service_AnalyticsReporting_Dimension(); $hitTime->setName("ga:dimension3"); + // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); $request->setViewId($VIEW_ID); From 795be997dd06f074f2bcc1b439095707cef44692 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Mon, 25 Mar 2019 20:31:09 +0800 Subject: [PATCH 10/13] refix3 --- application/controllers/gaapi.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index c2421810..f9823a11 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -60,7 +60,7 @@ class Gaapi extends CI_Controller // Create the DateRange object. $dateRange = new Google_Service_AnalyticsReporting_DateRange(); - $dateRange->setStartDate("3daysAgo"); + $dateRange->setStartDate("9daysAgo"); $dateRange->setEndDate("today"); // Create the Metrics object. @@ -68,7 +68,6 @@ class Gaapi extends CI_Controller $pv->setExpression("ga:pageviews"); $pv->setAlias("pageviews"); - //Create the dimensions $pageUrl = new Google_Service_AnalyticsReporting_Dimension(); $pageUrl->setName("ga:pagePath"); @@ -77,6 +76,11 @@ class Gaapi extends CI_Controller $hitTime = new Google_Service_AnalyticsReporting_Dimension(); $hitTime->setName("ga:dimension3"); + //fliter + $dimensionFilter = new Google_Service_AnalyticsReporting_SegmentDimensionFilter(); + $dimensionFilter->setDimensionName("ga:dimension1"); + $dimensionFilter->setOperator("EXACT"); + $dimensionFilter->setExpressions(array("1339237903.1553451389")); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); @@ -84,6 +88,7 @@ class Gaapi extends CI_Controller $request->setDateRanges($dateRange); $request->setMetrics(array($pv)); $request->setDimensions(array($pageUrl, $cid, $hitTime)); + $request->setDimensionFilter($dimensionFilter); $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); $body->setReportRequests(array($request)); From 936e9bbeeacd211cf1b53e70a4b753c8ac4f857c Mon Sep 17 00:00:00 2001 From: "lmr@hainatravel.com" <59361885@qq.com> Date: Mon, 25 Mar 2019 09:34:47 -0500 Subject: [PATCH 11/13] refix 4 --- application/controllers/gaapi.php | 62 ++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/application/controllers/gaapi.php b/application/controllers/gaapi.php index f9823a11..33003782 100644 --- a/application/controllers/gaapi.php +++ b/application/controllers/gaapi.php @@ -16,8 +16,9 @@ class Gaapi extends CI_Controller public function user_track() { + $cid = $this->input->get_post('cid'); $analytics = $this->initializeAnalytics(); - $response = $this->getReport($analytics); + $response = $this->getReport($analytics, $cid); $this->printResults($response); } @@ -37,7 +38,7 @@ class Gaapi extends CI_Controller // Create and configure a new client object. $client = new Google_Client(); - $client->setApplicationName("Hello Analytics Reporting"); + $client->setApplicationName("User Tracker"); $client->setAuthConfig($KEY_FILE_LOCATION); $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); $analytics = new Google_Service_AnalyticsReporting($client); @@ -52,15 +53,16 @@ class Gaapi extends CI_Controller * @param service An authorized Analytics Reporting API V4 service object. * @return The Analytics Reporting API V4 response. */ - function getReport($analytics) + function getReport($analytics, $cid_no) { + //die($cid); // Replace with your view ID, for example XXXX. $VIEW_ID = "68484932"; // Create the DateRange object. $dateRange = new Google_Service_AnalyticsReporting_DateRange(); - $dateRange->setStartDate("9daysAgo"); + $dateRange->setStartDate("30daysAgo"); $dateRange->setEndDate("today"); // Create the Metrics object. @@ -75,12 +77,24 @@ class Gaapi extends CI_Controller $cid->setName("ga:dimension1"); $hitTime = new Google_Service_AnalyticsReporting_Dimension(); $hitTime->setName("ga:dimension3"); - - //fliter - $dimensionFilter = new Google_Service_AnalyticsReporting_SegmentDimensionFilter(); - $dimensionFilter->setDimensionName("ga:dimension1"); - $dimensionFilter->setOperator("EXACT"); - $dimensionFilter->setExpressions(array("1339237903.1553451389")); + $ip = new Google_Service_AnalyticsReporting_Dimension(); + $ip->setName("ga:dimension3"); + + // Create Dimension Filter 1 + $cidFilter = new Google_Service_AnalyticsReporting_DimensionFilter(); + $cidFilter->setDimensionName("ga:dimension1"); + $cidFilter->setOperator('EXACT'); + $cidFilter->setExpressions($cid_no); + + // Create the DimensionFilterClauses + $dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause(); + $dimensionFilterClause->setFilters(array($cidFilter)); + + // OrderBy maybe some bugs + $order = new Google_Service_AnalyticsReporting_OrderBy; + $order->setFieldName("ga:dimension3"); + $order->setOrderType("VALUE"); + $order->setSortOrder("DESCENDING"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); @@ -88,7 +102,8 @@ class Gaapi extends CI_Controller $request->setDateRanges($dateRange); $request->setMetrics(array($pv)); $request->setDimensions(array($pageUrl, $cid, $hitTime)); - $request->setDimensionFilter($dimensionFilter); + $request->setDimensionFilterClauses(array($dimensionFilterClause)); + $request->setOrderBys(array($order)); $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); $body->setReportRequests(array($request)); @@ -97,36 +112,47 @@ class Gaapi extends CI_Controller /** - * Parses and prints the Analytics Reporting API V4 response. - * - * @param An Analytics Reporting API V4 response. - */ + * Parses and prints the Analytics Reporting API V4 response. + * + * @param An Analytics Reporting API V4 response. + */ function printResults($reports) { + $alais_array = array( + "ga:dimension1" => "cid", + "ga:dimension3" => "hitTime", + "ga:pagePath" => "path" + ); + $rs_array = array(); for ($reportIndex = 0; $reportIndex < count($reports); $reportIndex++) { $report = $reports[$reportIndex]; $header = $report->getColumnHeader(); $dimensionHeaders = $header->getDimensions(); $metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries(); $rows = $report->getData()->getRows(); - + $rs_row = array(); for ($rowIndex = 0; $rowIndex < count($rows); $rowIndex++) { $row = $rows[$rowIndex]; $dimensions = $row->getDimensions(); $metrics = $row->getMetrics(); for ($i = 0; $i < count($dimensionHeaders) && $i < count($dimensions); $i++) { - print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n"); + //print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n"); + $rs_row[$alais_array[$dimensionHeaders[$i]]] = $dimensions[$i]; } for ($j = 0; $j < count($metrics); $j++) { $values = $metrics[$j]->getValues(); for ($k = 0; $k < count($values); $k++) { $entry = $metricHeaders[$k]; - print($entry->getName() . ": " . $values[$k] . "\n"); + //print($entry->getName() . ": " . $values[$k] . "\n"); + $rs_row[$entry->getName()] = $values[$k]; } } + array_push($rs_array, $rs_row); } } + echo(json_encode($rs_array)); } + } //end of gaapi From 8d141575479ce3c7d124a1281104e48a5cdaff68 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 28 Mar 2019 09:59:06 +0800 Subject: [PATCH 12/13] =?UTF-8?q?AMP=20=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=9A=E5=AA=92=E4=BD=93=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/views/amp_editor.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/application/views/amp_editor.php b/application/views/amp_editor.php index ade80f75..26ebdd6f 100644 --- a/application/views/amp_editor.php +++ b/application/views/amp_editor.php @@ -16,6 +16,15 @@
+
+

多媒体中心图片

+
+ + + + +
+
@@ -94,6 +103,27 @@