You are here

protected function SimpleInstagramBlock::get_instagram_json in Simple Instagram Feed Block 1.0.x

Get Instagram data from non-private Instagram account page

Return value

array returns decoded Instagram array.

1 call to SimpleInstagramBlock::get_instagram_json()
SimpleInstagramBlock::build in src/Plugin/Block/SimpleInstagramBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/SimpleInstagramBlock.php, line 298

Class

SimpleInstagramBlock
Provides a block with a dynamic Instagram Feed.

Namespace

Drupal\simple_instagram_feed\Plugin\Block

Code

protected function get_instagram_json($username) {
  $instagram_source = file_get_contents('https://instagram.com/' . $username);
  $shards = explode('window._sharedData = ', $instagram_source);
  $instagram_json = explode(';</script>', $shards[1]);
  $instagram_array = json_decode($instagram_json[0], TRUE);
  return $instagram_array;
}