find('script') as $script) { $scriptContent = $script->text(); if (strpos($scriptContent, self::JS_VAR) !== FALSE) { $data = json_decode(trim(str_replace(self::JS_VAR, '', $scriptContent), ';'), TRUE); $edges = $data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']; foreach ($edges as $edge) { $items[] = $edge['node']; } } } return $items; } protected function _mapItems($content) { return array_map( function ($obj) { $item = new Item(); $item->ID = $obj['id']; $item->Link = sprintf( 'https://instagram.com/p/%s', $obj['shortcode'] ); $texts = array_filter( explode(PHP_EOL, $obj['edge_media_to_caption']['edges'][0]['node']['text']), function($t) { return $t != '.'; } ); $thumbs = $obj['thumbnail_resources']; if (count($thumbs)) { $texts[] = sprintf('', end($obj['thumbnail_resources'])['src']); } $item->Title = $texts[0]; $item->Text = implode('
', $texts); $item->Time = $obj['taken_at_timestamp']; return $item; }, $content ); } public function title() { return sprintf("%s's instagram posts", $this->_feed); } } ?>