DjMikeS Posted October 7, 2008 Share Posted October 7, 2008 Hi all, I've got this script to read an rss feed and display it on my website. I only want it to display the first 10 records, and leave out any items that don't belong to the "nieuws" (in english: news) category. So far so good though I think it can be done a little nicer... The real problem is that it doesn't seem to reload the feed when I reload my website...I still see the old news items while the feed has been updated... Do you know how to solve this? My code: <?php try { $strFeed = "http://feeds.feedburner.com/tweakers/mixed"; if (!$sxml = simplexml_load_file($strFeed)) { $strError = "RSS feed not available at this moment"; Throw New Exception(); } $i = 0; foreach ($sxml->channel->item as $item){ if (stristr($item->category, 'Nieuws') AND $i < 10) { echo "<li><b><a href=\"$item->link\">$item->title</a></b></li>\n"; $i++; } } unset ($sxml); } catch (Exception $e) { echo $strError; } ?> Quote Link to comment Share on other sites More sharing options...
tmallen Posted October 7, 2008 Share Posted October 7, 2008 Do you know if some sort "expires" header involved? Feedburner may even be limiting your IP's refreshes, who knows. Nothing relevant here: http://us.php.net/manual/en/function.simplexml-load-file.php , but you may want to browse that part of the Manual. Quote Link to comment Share on other sites More sharing options...
DjMikeS Posted October 7, 2008 Author Share Posted October 7, 2008 Thnx tmallen, I know feedburner isn't limiting my ip, because when I open the feed in my browser I can refresh as much as I like... I think php is caching the feed or something... The other solution would be to create a cronjob that automagically downloads the correct file every hour or so...but I would like to have it in sync.... edit: I read something about the headers so I added this to my site: header('Expires: Fri, 25 Dec 1980 00:00:00 GMT'); // time in the past header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: text/html'); But no luck yet.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.