You are here

public static function PiwikData::getResponse in Piwik Reports 8

Return server request results.

Parameters

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

Return value

string Decoded server response.

2 calls to PiwikData::getResponse()
PiwikData::getSites in src/PiwikData.php
Return a list of sites where statistics are accessible on piwik server.
PiwikReportsController::piwik_reports_get_goals in src/Controller/PiwikReportsController.php
Return a list of goals active on selected site.

File

src/PiwikData.php, line 40
Contains \Drupal\piwik_reports\PiwikData.

Class

PiwikData

Namespace

Drupal\piwik_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;
  }
}