apiBaseUrl . '/news_list/0?page=1&limit=10'; $listJson = getContents($listUrl); $listData = json_decode($listJson, true); if (!isset($listData['data']['list']) || !is_array($listData['data']['list'])) { returnServerError('Could not find list array in news list response'); } foreach ($listData['data']['list'] as $newsItem) { $newsId = $newsItem['Id']; // Fetch detailed news content $newsUrl = $this->apiBaseUrl . '/news/' . $newsId; try { $newsJson = getContents($newsUrl); $newsData = json_decode($newsJson, true); if (!$newsData || !isset($newsData['data'])) { continue; // Skip if news data is invalid } $article = $newsData['data']; $item = []; // Title $item['title'] = $article['Title'] ?? $newsItem['Title'] ?? 'Untitled'; // Content $item['content'] = $article['Content'] ?? ''; // URI - construct a link to the news page $typeId = $article['Type'] ?? $newsItem['Type'] ?? 0; $item['uri'] = 'https://gf2exilium.sunborngame.com/NewsInfo?id=' . $newsId . '&typeId=' . $typeId; // Timestamp if (isset($article['Date'])) { $item['timestamp'] = strtotime($article['Date']); } elseif (isset($newsItem['Date'])) { $item['timestamp'] = strtotime($newsItem['Date']); } // Author $item['author'] = 'Operations Team'; // UID $item['uid'] = 'gf2-exilium-' . $newsId; $this->items[] = $item; } catch (Exception $e) { // Skip articles that fail to load continue; } } } }