PHP library for french radio. RFrance a class to scrape and parse r a d i o f r a n c e
- php >= 8.0
- Use the package manager composer to install RFrance.
composer require flatgreen/rfrance
- Optional: Create a 'cache' directory (with read|write permissions), by default the cache directory is inside the system temporary directory.
require_once 'vendor/autoload.php';
use Flatgreen\RFrance\RFrance;
Instantiate the class, with an URL page
$rf = new RFrance(); // optional in constructor, add cache directory and cache duration for page, 1 day by default.
try {
$rf->extract(URL); // optional: set a (approx.) limit $max_items (default: -1, all items)
} catch (\Throwable $th) {
//throw $th;
}
Read the informations
if (empty($rf->error)){
$title = $rf->page->title;
$all_items = $rf->all_items; // array of Item
}
An Item always return an (audio media) url. This is the best
the class can find (see Item.php for information).
Three output helpers :
// to array
echo $FC->toArray();
// RSS 2.0
header("Content-Type: text/xml; charset=UTF-8");
echo $FC->toRss();
// or
// youtube-dl|yt-dlp info.json like
header('Content-Type: application/json; charset=utf-8');
echo $FC->toInfoJson();
Does not take into account pages that are not broadcasts.
RFrance is licensed under the MIT License (MIT). Please see the license file for more information.