Commit 8d4b0a7384e2493d36e0db7e55a3de2b78fe7ddd

Authored by Alex Savenko
1 parent a2842f96

ga

backend/controllers/ReportController.php
@@ -17,25 +17,13 @@ class ReportController extends Controller @@ -17,25 +17,13 @@ class ReportController extends Controller
17 17
18 return $this->render('index', [ 18 return $this->render('index', [
19 ]); 19 ]);
  20 +
20 } 21 }
21 22
22 public function actionCallback() { 23 public function actionCallback() {
23 - // Создание объекта клиента и установка конфигурации авторизации  
24 - // из файла client_secrets.json, скачанного из Developers Console.  
25 - $client = new Google_Client();  
26 - $client->setAuthConfig(__DIR__ . '/client_secrets.json');  
27 - $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/admin/report/callback');  
28 - $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);  
29 -  
30 - // Выполнение процесса авторизации с сервера.  
31 - if (! isset($_GET['code'])) {  
32 - $auth_url = $client->createAuthUrl();  
33 - header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));  
34 - } else {  
35 - $client->authenticate($_GET['code']);  
36 - $_SESSION['access_token'] = $client->getAccessToken();  
37 - $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';  
38 - header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));  
39 - } 24 +
  25 + return $this->render('callback', [
  26 + ]);
  27 +
40 } 28 }
41 } 29 }
42 \ No newline at end of file 30 \ No newline at end of file
backend/views/report/callback.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: HP
  5 + * Date: 04.01.2017
  6 + * Time: 15:13
  7 + */
  8 +
  9 +// Создание объекта клиента и установка конфигурации авторизации
  10 +// из файла client_secrets.json, скачанного из Developers Console.
  11 +$client = new Google_Client();
  12 +$client->setAuthConfig(__DIR__ . '/client_secrets.json');
  13 +$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/admin/report/callback');
  14 +$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
  15 +
  16 +// Выполнение процесса авторизации с сервера.
  17 +if (! isset($_GET['code'])) {
  18 + $auth_url = $client->createAuthUrl();
  19 + header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
  20 +} else {
  21 + $client->authenticate($_GET['code']);
  22 + $_SESSION['access_token'] = $client->getAccessToken();
  23 + $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
  24 + header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
  25 +}
0 \ No newline at end of file 26 \ No newline at end of file