Files
silly-rss/php/facebook.php
T
paraandClaude Sonnet 5 113616995f Serve feeds as text/xml instead of application/rss+xml
Browsers (Firefox in particular) force-download application/rss+xml and
application/atom+xml instead of rendering them, which is confusing for
site visitors who click a feed link directly rather than pasting it into
a reader. text/xml renders inline as an XML tree in every major browser.
Feed readers (FreshRSS included) sniff the actual XML content to detect
RSS/Atom, so this has no effect on subscription behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-25 23:34:30 +02:00

45 lines
1.3 KiB
PHP

<?php
require __DIR__ . '/common.php';
/**
* Proxy/cache du flux Facebook (page communedesilly) genere par
* FetchRSS (https://fetchrss.com). Scraper Facebook nous-memes n'est
* pas fiable (mur de connexion, blocage anti-bot systematique -
* confirme aussi en cassant l'instance RSS-Bridge testee) ; FetchRSS
* s'en charge et on se contente de re-servir/cacher son flux sous
* notre propre domaine pour avoir une URL stable a partager.
*/
const FETCHRSS_URL = 'https://fetchrss.com/feed/1xABzW0ZB9CM1xAByX0rYAhW.atom';
function fetch_facebook_feed(): string
{
return http_get(FETCHRSS_URL, ['Accept: application/atom+xml, application/xml']);
}
// text/xml plutot que application/atom+xml : voir la note dans common.php
header('Content-Type: text/xml; charset=utf-8');
if (!is_dir(CACHE_DIR)) {
mkdir(CACHE_DIR, 0775, true);
}
$cacheFile = CACHE_DIR . '/facebook.xml';
if (is_file($cacheFile) && (time() - filemtime($cacheFile)) < CACHE_TTL_SECONDS) {
readfile($cacheFile);
return;
}
try {
$xml = fetch_facebook_feed();
file_put_contents($cacheFile, $xml);
echo $xml;
} catch (Throwable $e) {
if (is_file($cacheFile)) {
readfile($cacheFile);
return;
}
http_response_code(502);
header('Content-Type: text/plain; charset=utf-8');
echo 'Erreur de recuperation du flux Facebook : ' . $e->getMessage();
}