By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

PHP RSS XML newsreader

P: n/a
Hi all,
I hope someone can help,
I've made an RSS xml newsreader in flash that reads rss files from
syndicated news sites, but a lot of these companies get a bit upset if
you access the feed too often.
What I'm hoping someone has is a small php script that will goto
"whatever" site every 30 mins and make a copy os the rss file to the
local server where my site is hosted.
All I need the php script to do is make a copy of it, not parse it.
Thanks in advance if you can help.

Marcos

pd: please include the full script due I am new with php.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ARGENTINA wrote:
Hi all,
I hope someone can help,
I've made an RSS xml newsreader in flash that reads rss files from
syndicated news sites, but a lot of these companies get a bit upset if
you access the feed too often.
What I'm hoping someone has is a small php script that will goto
"whatever" site every 30 mins and make a copy os the rss file to the
local server where my site is hosted.
All I need the php script to do is make a copy of it, not parse it.
Thanks in advance if you can help.

Marcos

pd: please include the full script due I am new with php.


Use a crontab like the following:

30 * * * * wget -O feed.html http://rss.feed.url
JW

Jul 17 '05 #2

P: n/a
On 16 Jan 2005 06:57:01 -0800, sj****@yahoo.com (ARGENTINA) posted:
Hi all,
I hope someone can help,
I've made an RSS xml newsreader in flash that reads rss files from
syndicated news sites, but a lot of these companies get a bit upset if
you access the feed too often.
What I'm hoping someone has is a small php script that will goto
"whatever" site every 30 mins and make a copy os the rss file to the
local server where my site is hosted.
All I need the php script to do is make a copy of it, not parse it.
Thanks in advance if you can help. Marcos pd: please include the full script due I am new with php.


Here's the way I do it...

define(LOCAL, "0");
define(REMOTE, "1");

$location = LOCAL;
$xml_file = array("local.xml", "remote.xml");
$cur_time = date("U");
$xml_file_time = filemtime($xml_file[LOCAL]);
if ($cur_time - $xml_file_time > 60 * 30) //every 30 minutes
$location = REMOTE;

$fp = fopen($xml_file[$location],"r");

if (!$fp) { //if first open fails, open previously saved file.
$location = LOCAL;
$fp = fopen($xml_file[LOCAL],"r");
}
elseif ($location) //or also open remote file, too
$fplocal = fopen($xml_file[LOCAL],"w");
/*
note the local file is not opened for a write if the remote file
could not be opened, so we always have the local file to read
*/
while ($data = fread($fp, 4096)) {
if ($fplocal and $data)
fwrite($fplocal, $data, 4096);
xml_parse($xml_parse, $data, feof($fp));
}

if ($fp)
fclose($fp);

if ($fplocal)
fclose($fplocal);

//--------Mike Soja

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.