Files
silly-rss/php/facebook.php
T
paraandClaude Sonnet 5 8205bfdffc Add PHP variant: no-cron, request-time feed generation for shared hosting
Same imio.smartweb JSON API as the Python script, but each feed regenerates
on demand (15 min file cache) instead of via cron, so it works on plain
PHP shared hosting with no server config access. Also adds facebook.php,
a caching proxy for the user's FetchRSS Atom feed so all three feeds live
under one domain and can be shared as stable URLs.

Tested with PHP 8.3 CLI: valid XML, real data (40 news, 12 events, proxied
Facebook feed).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-25 22:05:26 +02:00

44 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']);
}
header('Content-Type: application/atom+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();
}