[英]How to save rss feeds?
I am a newbie to programming and recently made a rss feeds for my app. 我是编程的新手,最近为我的应用制作了RSS供稿。 Now can anyone gimme a idea bout how I can save rss feeds to my local box from an external rss feeds url. 现在,任何人都可以给我一个想法,关于如何将外部供稿网址中的RSS供稿保存到本地框中。 Thanks 谢谢
Assuming you wanted to read the contents and then save to a local file, you could do the following: 假设您想阅读内容然后保存到本地文件,则可以执行以下操作:
$feedurl = "http://someurl/feed/";
$feedme = file_get_contents($feedurl);
if($feedme):
$fh = fopen('path/to/newfeed.xml', 'w+'); //create new file if not exists
fwrite($fh, $feedme) or die("Failed to write contents to new file"); //write contents to new XML file
fclose($fh) or die("failed to close stream resource"); //close resource stream
else:
die("Failed to read contents of feed at $feedurl");
endif;
That is a REALLY simple example to get you started. 这是一个非常简单的示例,可以帮助您入门。
I would suggest to use cURL to retrieve the data and any xml-parser to analyze. 我建议使用cURL检索数据,并使用任何xml解析器进行分析。 Or just use google ;-) -> using-php-curl-to-read-rss-feed-xml 或者只是使用google ;-)-> using-php-curl-to-read-rss-feed-xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.