You are here

protected function InstagramAccount::extractInstagramData in Instagram Feeds 8

Extracts Instagram data from Guzzle response.

Parameters

\GuzzleHttp\Psr7\Response $response: Guzzle response.

Return value

array Extracted Instagram data.

Throws

\Exception

3 calls to InstagramAccount::extractInstagramData()
InstagramAccount::getAccountName in src/Entity/InstagramAccount.php
Gets Instagram account username.
InstagramAccount::refreshToken in src/Entity/InstagramAccount.php
Tries to refresh long-lived Instagram access token.
InstagramAccount::setNewToken in src/Entity/InstagramAccount.php
Obtains short-lived token and exchanges it to long-lived one.

File

src/Entity/InstagramAccount.php, line 267

Class

InstagramAccount
Defines the instagram_account entity class.

Namespace

Drupal\instagram_feeds\Entity

Code

protected function extractInstagramData($response) {
  $body = Json::decode($response
    ->getBody()
    ->getContents());
  if ($response
    ->getStatusCode() !== 200) {
    throw new \Exception($body['error_message'], $response
      ->getStatusCode());
  }
  return $body;
}