Commit d6c4c133df13bb19b716b3c8ac74a2cd8c94d96a
1 parent
ff25157e
ga response
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
app/library/App/Controllers/GaController.php
| @@ -25,13 +25,15 @@ class GaController extends CrudResourceController { | @@ -25,13 +25,15 @@ class GaController extends CrudResourceController { | ||
| 25 | 25 | ||
| 26 | public function getAction() { | 26 | public function getAction() { |
| 27 | 27 | ||
| 28 | + $metric = $this->request->getServer('metric'); | ||
| 29 | + | ||
| 28 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); | 30 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); |
| 29 | $client = new Google_Client(); | 31 | $client = new Google_Client(); |
| 30 | $client->useApplicationDefaultCredentials(); | 32 | $client->useApplicationDefaultCredentials(); |
| 31 | $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); | 33 | $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); |
| 32 | $analytics = new Google_Service_AnalyticsReporting($client); | 34 | $analytics = new Google_Service_AnalyticsReporting($client); |
| 33 | 35 | ||
| 34 | - $param[] = ['metric' => 'ga:sessions', 'alias' => 'Сессии']; | 36 | + $param[] = ['metric' => $metric]; |
| 35 | 37 | ||
| 36 | $response = []; | 38 | $response = []; |
| 37 | 39 | ||
| @@ -45,7 +47,7 @@ class GaController extends CrudResourceController { | @@ -45,7 +47,7 @@ class GaController extends CrudResourceController { | ||
| 45 | // Создание объекта Metrics. | 47 | // Создание объекта Metrics. |
| 46 | $sessions = new Google_Service_AnalyticsReporting_Metric(); | 48 | $sessions = new Google_Service_AnalyticsReporting_Metric(); |
| 47 | $sessions->setExpression($item['metric']); | 49 | $sessions->setExpression($item['metric']); |
| 48 | - $sessions->setAlias($item['alias']); | 50 | + //$sessions->setAlias($item['alias']); |
| 49 | 51 | ||
| 50 | 52 | ||
| 51 | // Создание объекта ReportRequest. | 53 | // Создание объекта ReportRequest. |