diff --git a/assets/css/custom.css b/assets/css/custom.css index 0a8d757..15326c0 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -192,3 +192,33 @@ body { font-size: 0.875rem; color: #6C757D; } + +.integration-connect { + margin-bottom: 32px; + padding: 24px; + background-color: #FFFFFF; + border: 1px solid #DEE2E6; + border-radius: 8px; + text-align: center; +} + +.btn { + padding: 12px 24px; + font-size: 1rem; + border-radius: 4px; + cursor: pointer; + text-decoration: none; + font-weight: 500; + display: inline-block; +} + +.btn-primary { + background-color: #007BFF; + color: #FFFFFF; + border: 1px solid #007BFF; +} + +.btn-primary:hover { + background-color: #0056b3; + border-color: #0056b3; +} diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..284446f --- /dev/null +++ b/config/.gitignore @@ -0,0 +1 @@ +google.php diff --git a/dashboard.php b/dashboard.php index 9d04fc8..f1ee517 100644 --- a/dashboard.php +++ b/dashboard.php @@ -43,6 +43,9 @@ $chart_data = [
+
+ Connect to Google Analytics +

's Dashboard

diff --git a/google_auth.php b/google_auth.php new file mode 100644 index 0000000..be3f51f --- /dev/null +++ b/google_auth.php @@ -0,0 +1,16 @@ + GOOGLE_CLIENT_ID, + 'redirect_uri' => GOOGLE_REDIRECT_URI, + 'response_type' => 'code', + 'scope' => 'https://www.googleapis.com/auth/analytics.readonly', + 'access_type' => 'offline', + 'prompt' => 'consent' +]); + +header('Location: ' . $auth_url); +exit(); diff --git a/google_callback.php b/google_callback.php new file mode 100644 index 0000000..f79f379 --- /dev/null +++ b/google_callback.php @@ -0,0 +1,48 @@ + $code, + 'client_id' => GOOGLE_CLIENT_ID, + 'client_secret' => GOOGLE_CLIENT_SECRET, + 'redirect_uri' => GOOGLE_REDIRECT_URI, + 'grant_type' => 'authorization_code' + ]; + + $ch = curl_init($token_url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($token_params)); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($http_code == 200) { + $token_data = json_decode($response, true); + + // For now, just print the token data + // In a real application, you would store this securely in a database + echo '
';
+        print_r($token_data);
+        echo '
'; + + // Store the access token in the session for immediate use + $_SESSION['google_access_token'] = $token_data['access_token']; + + // Redirect back to the dashboard + // header('Location: dashboard.php'); + // exit(); + + } else { + echo "Error fetching access token: " . $response; + } +} else { + echo "Authorization code not found."; +}