diff --git a/backend/views/report/index.php b/backend/views/report/index.php index 2d28cf5..a974078 100644 --- a/backend/views/report/index.php +++ b/backend/views/report/index.php @@ -44,17 +44,9 @@ if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { // Вывод ответа. printResults($response); + printDataTable($response); - try { - $results = queryCoreReportingApi(); - // Success. Do something cool! - - } catch (apiServiceException $e) { - // Handle API service exceptions. - $error = $e->getMessage(); - } - } else { $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/admin/report/callback'; header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); @@ -117,19 +109,34 @@ function printResults($reports) { } } -function queryCoreReportingApi() { - $optParams = array( - 'dimensions' => 'ga:source,ga:keyword', - 'sort' => '-ga:sessions,ga:source', - 'filters' => 'ga:medium==organic', - 'max-results' => '25'); - - return $service->data_ga->get( - TABLE_ID, - '2010-01-01', - '2010-01-15', - 'ga:sessions', - $optParams); +private function printDataTable(&$results) { + if (count($results->getRows()) > 0) { + $table .= ''; + + // Print headers. + $table .= ''; + + foreach ($results->getColumnHeaders() as $header) { + $table .= ''; + } + $table .= ''; + + // Print table rows. + foreach ($results->getRows() as $row) { + $table .= ''; + foreach ($row as $cell) { + $table .= ''; + } + $table .= ''; + } + $table .= '
' . $header->name . '
' + . htmlspecialchars($cell, ENT_NOQUOTES) + . '
'; + + } else { + $table .= '

No Results Found.

'; + } + print $table; } -- libgit2 0.21.4