- Recurring events share one UID across all occurrences (confirmed via the API: same UID, different start dates), which produced duplicate <guid> values the RSS spec forbids. Suffix the guid with the occurrence's start date to make it unique per occurrence. - Add atom:link rel="self" to the channel, per the validator's recommendation, in both the PHP and Python implementations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
require __DIR__ . '/common.php';
|
|
|
|
const SITE = 'https://www.silly.be';
|
|
const NEWS_API = SITE . '/actualites/@results';
|
|
const PAGE_SIZE = 20;
|
|
const MAX_PAGES = 2; // jusqu'a 40 items
|
|
|
|
function fetch_all_news(): array
|
|
{
|
|
$items = [];
|
|
for ($page = 0; $page < MAX_PAGES; $page++) {
|
|
$bStart = $page * PAGE_SIZE;
|
|
$url = NEWS_API . '?b_size=' . PAGE_SIZE . '&b_start=' . $bStart;
|
|
$data = json_decode(http_get($url), true);
|
|
$pageItems = $data['items'] ?? [];
|
|
if (empty($pageItems)) {
|
|
break;
|
|
}
|
|
$items = array_merge($items, $pageItems);
|
|
if (count($items) >= ($data['items_total'] ?? 0)) {
|
|
break;
|
|
}
|
|
}
|
|
return $items;
|
|
}
|
|
|
|
function build_news_feed(): string
|
|
{
|
|
$items = [];
|
|
foreach (fetch_all_news() as $item) {
|
|
$id = $item['id'] ?? '';
|
|
$title = $item['title_fr'] ?? $item['title'] ?? '(sans titre)';
|
|
$uid = $item['UID'] ?? $id;
|
|
$items[] = [
|
|
'title' => $title,
|
|
'link' => SITE . '/actualites/' . slugify($title) . '?u=' . rawurlencode($uid),
|
|
'guid' => $uid,
|
|
'pubDate' => $item['effective'] ?? $item['created'] ?? null,
|
|
'description' => full_body_html($item),
|
|
];
|
|
}
|
|
return build_rss(
|
|
'Silly.be - Actualités',
|
|
SITE . '/actualites',
|
|
'Actualités de la commune de Silly (Belgique)',
|
|
$items,
|
|
'https://sillycone-village.be/silly-rss/actualites.php'
|
|
);
|
|
}
|
|
|
|
serve_cached_feed('actualites', 'build_news_feed');
|