'all', 'setNumber' => '0', 'sortByVideo' => 'all', 'sortByTopic' => 'all' ]; $api_endpoint = '/api/TGNWebAPI/Get_Filtered_Article_Set?'; $apiUrl = self::URI . $api_endpoint . http_build_query($params); $rawContent = getContents($apiUrl); $cleanedContent = str_replace('\r\n', '', substr($rawContent, 1, -1)); $cleanedContent = str_replace('\"', '"', $cleanedContent); // The content is actually a json between quotes with \r\n inserted $json = json_decode($cleanedContent); foreach ($json as $article) { $item = []; $articleUri = self::URI . '/' . $article->{'_system_'}->name; $item['uri'] = $articleUri; $item['title'] = $article->headline; $item['content'] = self::getItemContent($articleUri); $item['timestamp'] = strtotime($article->date); $this->items[] = $item; } } protected function getItemContent($articleUri) { // We need to change the headers as the normal desktop website // use canvas-based image carousels for some pictures $headers = [ 'User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', ]; $article_html = getSimpleHTMLDOMCached($articleUri, 86400, $headers); $content = ''; if (!$article_html) { $content .= '
Could not request ' . $this->getName() . ': ' . $articleUri . '
'; return $content; } $article_html = defaultLinkTo($article_html, $this->getURI()); $top_description = '' . $article_html->find('div.article_top_description', 0)->innertext . '
'; $hero_image = '