douduanque5850 2016-04-21 14:09
浏览 54

从服务器文件夹创建自动RSS源

I have a VPS web server with PHP installed and have several folders with audio recordings from school. I would like to generate an RSS feed for each folder, listing the .mp3 files in alphabetical order (since they contain a number prefix like 001-filename). Is there any way to do this that currently works? I have found these 2 scripts online but none of them seem to work for me.

  1. http://dircaster.org/index.html

  2. https://gist.github.com/vsoch/4898025919365bf23b6f

N°2 seems like the most simple script, but if I edit the variables and upload it to the appropriate folder, it does not seem to work. This is the result I get navigating to my page:

?xml version="1.0"?> 0) { $files[]['name'] = $file; $files[]['timestamp'] = filectime($file); } } closedir($dir); // natcasesort($files); - we will use dates and times to sort the list. for($i=0; $i "; echo " "; echo " ". $feedBaseURL . $files[$i]['name'] . " "; echo " ". $feedBaseURL . $files[$i]['name'] . " "; // echo " ". date("D M j G:i:s T Y", $files[$i]['timestamp']) ." "; // echo " " . $files[$i]['timestamp'] ." "; echo " "; } } } ?>

This is my php -version PHP 5.6.17-0+deb8u1 (cli) (built: Jan 13 2016 09:10:12)

My end result should be this:

website.com/chemistry/ have an RSS feed for all the chemistry audio files

website.com/english/ have an RSS feed for all the english audio files

  • 写回答

3条回答 默认 最新

  • douqiang4501 2016-04-21 14:53
    关注

    Begin by taking the original github script, save it to a file (with an extension of .php) and upload that to your server to be sure it works as is. I get the following (in Chrome) (I changed the website name to example.com so I could post it here):

    <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
        <channel>
            <title>My Audio Feed</title>
            <link>http://www.example.com/audio</link>
            <description>Feed for the my audio files in some server folder</description>
            <atom:link href="http://gogglesoptional.com/bloopers" rel="self" type="application/rss+xml"/>
        </channel>
    </rss>
    

    If that works, try replacing <?= '?'; ?> with <?php echo '?'; ?> . The script from github includes php code mixed with XML, and your output suggests that something (syntax problem, missing <?php, etc) switched it from php-mode to xml when it wasn't intended.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥15 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)