diff --git a/BlueArchiveNewsBridge.php b/BlueArchiveNewsBridge.php new file mode 100644 index 0000000..7273738 --- /dev/null +++ b/BlueArchiveNewsBridge.php @@ -0,0 +1,79 @@ + [ + 'name' => 'Category', + 'type' => 'list', + 'values' => [ + 'All' => 'all', + 'Announcements' => '3028', + 'Updates' => '3217', + 'Events' => '3218', + ], + 'defaultValue' => '3028', + ], + ], + ]; + + public function collectData() { + $category = $this->getInput('category'); + $boardIds = []; + if ($category === 'all') { + $boardIds = ['3028', '3217', '3218']; + } else { + $boardIds = [$category]; + } + $allThreads = []; + foreach ($boardIds as $boardId) { + $jsonUrl = "https://forum.nexon.com/api/v1/board/{$boardId}/threads?alias=bluearchive-en&pageNo=1&paginationType=PAGING&pageSize=10&blockSize=5&hideType=WEB"; + $json = getContents($jsonUrl); + if (!$json) continue; + $data = json_decode($json, true); + if (!isset($data['threads'])) continue; + foreach ($data['threads'] as $thread) { + $thread['boardId'] = $boardId; // sicherstellen, dass boardId korrekt ist + $allThreads[] = $thread; + } + } + // Nach createDate absteigend sortieren + usort($allThreads, function($a, $b) { + return $b['createDate'] <=> $a['createDate']; + }); + // Maximal 10 insgesamt + $threads = array_slice($allThreads, 0, 10); + foreach ($threads as $thread) { + $item = array(); + $item['title'] = html_entity_decode($thread['title']); + $item['uri'] = 'https://forum.nexon.com/bluearchive-en/board_view?board=' . $thread['boardId'] . '&thread=' . $thread['threadId']; + $item['author'] = $thread['user']['nickname'] ?? ''; + $item['timestamp'] = $thread['createDate']; + $item['uid'] = $thread['threadId']; + $item['enclosures'] = array(); + // Fetch thread content + $threadApiUrl = 'https://forum.nexon.com/api/v1/thread/' . $thread['threadId'] . '?alias=bluearchive-en'; + $threadJson = @getContents($threadApiUrl); + if ($threadJson) { + $threadData = json_decode($threadJson, true); + if (isset($threadData['content']) && !empty($threadData['content'])) { + $item['content'] = $threadData['content']; + } else { + $item['content'] = ''; + } + } else { + $item['content'] = ''; + } + $this->items[] = $item; + } + } +} \ No newline at end of file