Commit ea2d4431f51d502d0579c5436096be49b6f11a0e
1 parent
3788618a
ga response
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
app/library/App/Controllers/GaController.php
| @@ -25,7 +25,7 @@ class GaController extends CrudResourceController { | @@ -25,7 +25,7 @@ class GaController extends CrudResourceController { | ||
| 25 | 25 | ||
| 26 | public function getAction() { | 26 | public function getAction() { |
| 27 | 27 | ||
| 28 | - $metric = $this->request->get('metric'); | 28 | + $getMetric = $this->request->get('metric'); |
| 29 | 29 | ||
| 30 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); | 30 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); |
| 31 | $client = new Google_Client(); | 31 | $client = new Google_Client(); |
| @@ -33,7 +33,7 @@ class GaController extends CrudResourceController { | @@ -33,7 +33,7 @@ class GaController extends CrudResourceController { | ||
| 33 | $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); | 33 | $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); |
| 34 | $analytics = new Google_Service_AnalyticsReporting($client); | 34 | $analytics = new Google_Service_AnalyticsReporting($client); |
| 35 | 35 | ||
| 36 | - $param[] = ['metric' => 'ga:'.$metric, 'alias' => 'alias']; | 36 | + $param = ['metric' => 'ga:'.$getMetric]; |
| 37 | 37 | ||
| 38 | $response = []; | 38 | $response = []; |
| 39 | 39 | ||
| @@ -45,16 +45,16 @@ class GaController extends CrudResourceController { | @@ -45,16 +45,16 @@ class GaController extends CrudResourceController { | ||
| 45 | $dateRange->setEndDate("today"); | 45 | $dateRange->setEndDate("today"); |
| 46 | 46 | ||
| 47 | // Создание объекта Metrics. | 47 | // Создание объекта Metrics. |
| 48 | - $sessions = new Google_Service_AnalyticsReporting_Metric(); | ||
| 49 | - $sessions->setExpression($item['metric']); | ||
| 50 | - $sessions->setAlias($item['alias']); | 48 | + $metrics = new Google_Service_AnalyticsReporting_Metric(); |
| 49 | + $metrics->setExpression($item['metric']); | ||
| 50 | + //$sessions->setAlias($item['alias']); | ||
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | // Создание объекта ReportRequest. | 53 | // Создание объекта ReportRequest. |
| 54 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); | 54 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); |
| 55 | $request->setViewId(self::VIEW_ID); | 55 | $request->setViewId(self::VIEW_ID); |
| 56 | $request->setDateRanges($dateRange); | 56 | $request->setDateRanges($dateRange); |
| 57 | - $request->setMetrics(array($sessions)); | 57 | + $request->setMetrics(array($metrics)); |
| 58 | 58 | ||
| 59 | $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); | 59 | $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); |
| 60 | $body->setReportRequests( array( $request) ); | 60 | $body->setReportRequests( array( $request) ); |