diff --git a/backend/controllers/ReportController.php b/backend/controllers/ReportController.php index 9f5954a..5d7a66b 100644 --- a/backend/controllers/ReportController.php +++ b/backend/controllers/ReportController.php @@ -17,25 +17,13 @@ class ReportController extends Controller return $this->render('index', [ ]); + } public function actionCallback() { - // Создание объекта клиента и установка конфигурации авторизации - // из файла client_secrets.json, скачанного из Developers Console. - $client = new Google_Client(); - $client->setAuthConfig(__DIR__ . '/client_secrets.json'); - $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/admin/report/callback'); - $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); - - // Выполнение процесса авторизации с сервера. - if (! isset($_GET['code'])) { - $auth_url = $client->createAuthUrl(); - header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL)); - } else { - $client->authenticate($_GET['code']); - $_SESSION['access_token'] = $client->getAccessToken(); - $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/'; - header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); - } + + return $this->render('callback', [ + ]); + } } \ No newline at end of file diff --git a/backend/views/report/callback.php b/backend/views/report/callback.php new file mode 100644 index 0000000..8d4aa7f --- /dev/null +++ b/backend/views/report/callback.php @@ -0,0 +1,25 @@ +setAuthConfig(__DIR__ . '/client_secrets.json'); +$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/admin/report/callback'); +$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); + +// Выполнение процесса авторизации с сервера. +if (! isset($_GET['code'])) { + $auth_url = $client->createAuthUrl(); + header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL)); +} else { + $client->authenticate($_GET['code']); + $_SESSION['access_token'] = $client->getAccessToken(); + $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/'; + header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); +} \ No newline at end of file -- libgit2 0.21.4