1
0
Files
Bridges/HazeReverbBridge.php
2025-12-03 21:37:23 +01:00

72 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
class HazeReverbBridge extends BridgeAbstract
{
const MAINTAINER = 'Akamaru';
const NAME = 'HazeReverb News';
const URI = 'https://www.hazereverb.com/';
const CACHE_TIMEOUT = 3600; // 1 hour
const DESCRIPTION = 'Returns news and announcements from HazeReverb';
public function getIcon()
{
return 'https://www.google.com/s2/favicons?domain=hazereverb.com&sz=32';
}
public function collectData()
{
// Fetch the blog list
$listUrl = 'https://www.hazereverb.com/prod-api/system/blog/blogList?pageNum=1&pageSize=15';
$listJson = getContents($listUrl)
or returnServerError('Could not fetch blog list from HazeReverb API');
$listData = json_decode($listJson, true);
if (!isset($listData['rows']) || !is_array($listData['rows'])) {
returnServerError('Invalid response format from blog list API');
}
// Process each news item
foreach ($listData['rows'] as $newsItem) {
$newsId = $newsItem['id'] ?? null;
$title = $newsItem['title'] ?? null;
$createTime = $newsItem['createTime'] ?? null;
$createBy = $newsItem['createBy'] ?? null;
if (!$newsId || !$title) {
continue;
}
// Fetch the detailed content for this news item
$detailUrl = 'https://www.hazereverb.com/prod-api/system/blog/blogDetail?id=' . urlencode($newsId);
$detailJson = getContents($detailUrl);
if (!$detailJson) {
continue;
}
$detailData = json_decode($detailJson, true);
$content = $detailData['content'] ?? '';
// Build the feed item
$item = [];
$item['title'] = $title;
$item['uri'] = 'https://www.hazereverb.com/news?id=' . $newsId;
$item['content'] = $content;
$item['uid'] = $newsId;
if ($createTime) {
$item['timestamp'] = strtotime($createTime);
}
if ($createBy) {
$item['author'] = $createBy;
}
$this->items[] = $item;
}
}
}