Skip to content

Instantly share code, notes, and snippets.

Last active February 15, 2024 08:38
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ilevantis/88f1f646b59c62f0466d to your computer and use it in GitHub Desktop.
Turn mixcloud streams into an RSS feed e.g. for<mixcloudstream>/playlists/<streamplaylist-if-there-is-one>/ go to<mixcloudstream>&lname=<streamplaylist-if-there-is-one> to get an RSS feed of the stream or the playlist from the stream
header('Content-Type: application/rss+xml; charset=UTF-8');
// suck in the query string variables
$feed_name = htmlspecialchars($_GET['fname']);
$list_name = htmlspecialchars($_GET['lname']);
// compose the api urls + other stuff depending on presence of playlist
if(isset($_GET['lname'])) {
$json_url = ''.$feed_name.'/playlists/'.$list_name.'/cloudcasts/';
$mcloud_url = ''.$feed_name.'/playlists/'.$list_name.'/';
$feed_title = $feed_name.': '.$list_name;
} else {
$json_url = ''.$feed_name.'/cloudcasts/';
$mcloud_url = ''.$feed_name.'/';
$feed_title = $feed_name;
// suck in json from mixcloud and turn into an array
$json = file_get_contents($json_url);
$feed_array = json_decode($json, true);
<?xml version="1.0" encoding="utf-8"?>
<rss version='2.0'>
<title><?php echo $feed_array[name]; ?></title>
<link><?php echo $mcloud_url; ?></link>
<description><?php echo 'RSS feed for '.$feed_title.' on'; ?></description>
<image><?php echo $feed_array[data][0][user][pictures][large]; ?></image>
// item loop stuff goes here
foreach ($feed_array[data] as $feed_item) {
echo "<item>\n";
echo "<title>";
echo $feed_item[name];
echo "</title>\n";
echo "<link>";
echo $feed_item[url];
echo "</link>\n";
echo "<description>";
echo '<![CDATA[<img src="'.$feed_item[pictures][extra_large].'">]]>';
echo "</description>\n";
echo "<pubDate>";
echo $feed_item[created_time];
echo "</pubDate>\n";
echo "</item>\n";
Copy link

HarHarLinks commented Mar 22, 2022

Hi, first of all thanks for publishing this. The parsing seems to work well, however I stumbled over my feed reader not accepting it. tells me:

I have addressed these issues in my fork:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment