Web Analytics Made Easy -
StatCounter PHP / RSS Podcast - CodingForum

Announcement

Collapse
No announcement yet.

PHP / RSS Podcast

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP / RSS Podcast

    Hi all,

    I've been stuck on this problem for 3 days...and now, I must find help.

    My goal is to have a podcast that is updated automatically on a daily basis without any intervention.

    All the podcasts are already recorded and the filenames are based on the date they should be made available. ie: 2006.09.28.mp3, 2006.09.29.mp3, 2006.09.30.mp3, etc.

    I have set an .htaccess file in the same folder as the .rss file so as to read the XML content as PHP.

    Content of .htaccess file:
    AddType application/x-httpd-php .xml
    The PHP code that I have is:
    <?php
    header('Content-type: text/rss+xml');
    echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";

    $today = date('Y.m.d');
    $mp3 = "http://www.domain.org/files/podcasts/$today.mp3";

    $today_string = date('F n, Y');
    $date = date('D, d M Y 00:00:00');

    ?>

    <rss version="2.0">
    <channel>
    <title>My Podcast</title>
    <link>http://www.domain.org</link>
    <description>All my podcasts</description>
    <language>en-us</language>
    <copyright>2006</copyright>
    <webMaster>[email protected]</webMaster>
    <ttl>1440</ttl>
    <?php echo "<lastBuildDate>$date PST</lastBuildDate>"; ?>

    <item>
    <?php echo "<title>Podcast for $today_string</title>"; ?>
    <description>My daily podcast for you to enjoy.</description>
    <?php echo "<pubDate>$date PST</pubdate>"; ?>

    <?php

    print "<enclosure url='".str_replace(" ", "%20", htmlspecialchars($mp3))."' length='32057' type='audio/mpeg'/>\n";

    ?>
    </item>
    </channel>
    </rss>
    Issues I am having/have had:

    1. PHP doesn't seem to like the enclosure tag. When I use PHP to print/echo it, it actually does so, but the aggregator doesn't "read" it apparently. I've tried SO many different ways to output it and from my research on the internet, this is the last one I came up with.

    2. Had issues with calculating the size of the .mp3 file, so I am hardcoding the "length" of the file for now. I can address this issue later as soon as the other problem is fixed.

    Using the above code, all the elements work and the feed validates, but the podcast is not loaded due to, what I TRULY believe is the problem with the <enclosure> tag.

    Ultimately, the feed should load into aggregators, including iTunes and Google Reader.

    Been pulling my hair out trying to find the solution, so any help is MUCH appreciated.

    PS: thought about using a CRON job to create a new .rss file daily, but that defeats the goal of having this be a simple solution for "non-techies" to handle.
Working...
X