You are here

public function SharrreCounterController::parse in Share Message 8

Parse the counter information.

Parameters

string $enc_url: URL to parse.

Return value

mixed Returns the content.

2 calls to SharrreCounterController::parse()
SharrreCounterController::getCounterGooglePlus in src/Controller/SharrreCounterController.php
Get the counter for Google Plus.
SharrreCounterController::getCounterStumbleupon in src/Controller/SharrreCounterController.php
Get the counter for Stumbleupon.

File

src/Controller/SharrreCounterController.php, line 98

Class

SharrreCounterController
Route controller class for the Sharrre - Google Plus and Stumbleupon counter.

Namespace

Drupal\sharemessage\Controller

Code

public function parse($enc_url) {
  try {
    $response = \Drupal::httpClient()
      ->request('GET', $enc_url);
  } catch (BadResponseException $e) {
    $error = $e
      ->getResponse()
      ->json();
    watchdog_exception('sharrre', $e, $error['error']['message']);
    return;
  }

  // Process the JSON result into array.
  return $response
    ->getBody()
    ->getContents();
}