PHP code example of mhrlab / youtube-rss
1. Go to this page and download the library: Download mhrlab/youtube-rss library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mhrlab / youtube-rss example snippets
$rss = new Feed('https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID');
if ($rss->error){
/* print error message */
echo $rss->errorMessage;
}else{
$array = $rss->toArray();
/*pass true to print json with header('content-type:application/json')*/
$rss->toJSON(true);
}
$rss = new Feed();
/*set time_zone to receive all time&date in own timezone. */
$rss->time_zone = 'asia/kolkata';
$rss->loadRss('https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID');
if ($rss->error){
/* print error message */
echo $rss->errorMessage;
}else{
$array = $rss->toArray();
/*pass true to print json with header('content-type:application/json')*/
$rss->toJSON(true);
}