简体   繁体   中英

create an automatic update RSS feed out of .txt file

我有一个.txt文件,其中包含许多行,我希望一些PHP脚本创建一个RSS feed,并每隔一定的时间(例如2分钟)逐行从.txt文件中进行更新。一个.txt文件包含100个文本行,该脚本将创建一个RSS Feed,并每2分钟用文本行对其进行更新,以便该文本行分别为N1,N2,N2,.....,N100行然后停止更新RSS feed],我希望我已经说清楚了,是否可行,(我在PHP或XML编程方面并不擅长,我在互联网上搜索了类似的内容,但找不到任何解决方案,希望您能对我有所帮助)。

This would take around half an hour to an hour to code and test.

The idea is:

  1. use file_get_contents to get the file into a variable
  2. split the file on "\\n" and store the resultant array into a variable
  3. use header to set the mime type to the one for RSS feeds
  4. echo the start of the RSS feed
  5. foreach line of the array, split on commas, if it is a csv and put each bit into a variable
  6. echo the relevant XML for each line (read RSS spec to find out what it is)
  7. echo the end of the RSS feed

Then submit to the RSS validator and tweak until it's valid

Then use cron to run the file regularly

This would be a very good place to learn some PHP – follow what I've said, and it won't be too painful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM