You are here

public static function MatomoData::getResponse in Matomo Reports 8

Return server request results.

Parameters

string $query_url: URL and query string to pass to matomo server.

Return value

string Decoded server response.

2 calls to MatomoData::getResponse()
MatomoData::getSites in src/MatomoData.php
Return a list of sites where statistics are accessible on matomo server.
MatomoReportsController::getGoals in src/Controller/MatomoReportsController.php
Return a list of goals active on selected site.

File

src/MatomoData.php, line 38

Class

MatomoData
Utility class for data retrieved by reports.

Namespace

Drupal\matomo_reports

Code

public static function getResponse($query_url) {
  try {
    $response = \Drupal::httpClient()
      ->get($query_url);
    $data = (string) $response
      ->getBody();
    if (empty($data)) {
      return FALSE;
    }
    else {
      return Json::decode($data);
    }
  } catch (RequestException $e) {
    return FALSE;
  }
}