PDA

Click to See Complete Forum and Search --> : getFeed Question


Olly79
May 23rd, 2009, 10:43 AM
Hi all,

I'm retrieving an XML feed via php:

<?php
header('Content-type: text/xml');
echo file_get_contents('http://www.somexmlfeed.com/feed.xml');
?>

Now this is working fine and I'm able to work with the XML data to populate my website - this data is only updated when the page is refreshed; therefore I wondered if there was a way I could send out this request every couple of seconds without a page refresh?

Any help much appreciated as I'm struggling with this.

manavo11
May 23rd, 2009, 06:31 PM
Without a page refresh? I guess the only way would be with javascript/ajax. Or you can automate the refresh by using something like:

header( 'refresh: 5; url=page.php' );

kows
May 24th, 2009, 03:40 AM
my initial assumption is that you wanted to update this feed data whether or not your site is actually visited or not. you can make a script that updates it and add it as a scheduled task (windows) or a cron job (unix). to run every minute, or something. running every few seconds would be a little pointless.

but if you actually wanted real time updates on your website, there isn't really any way to efficiently do it that I know of. facebook does something a little like this, but I'm not sure to what extent. if I leave my browser open and come back a few hours later, my "friend feed" will be updated with a link that tells me "X new posts" were posted since my last refresh, which I can then click on and it will run ajax to update the feed. so, yeah, it's probably possible to do real time updates, as well! but, I've not looked into how they do it either.

most sites just put things like that in an iframe, and have it refresh every 10-20 seconds.