billy2shoe Posted February 3, 2007 Share Posted February 3, 2007 does anyone have any simple RSS code that works .. i would like to learn about this... (please dont post a site..as all the sites i find with code seem not to work????) http://www.phpit.net/article/screenscrap-rss/2/ what would be awesome is someone that has an example that WORKS.. ie returns something when u run it Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/ Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 this snippet of code will read and parse the RSS feed XML file: <?php // The @ is to supress the function´ errors $newsfeed = 'http://url/to/file.xml'; $fp = @fopen($newsfeed, 'r'); while(!feof($fp)){ $row .= @fgets($fp, 4096); } @fclose($fp); if( eregi('<item>(.*)</item>', $row, $rowitem ) ) { $item = explode('<item>', $rowitem[0]); for( $i = 0; $i < count($item) - 1; $i ) { eregi('<title>(.*)</title>', $item[$i 1], $title ); eregi('<url>(.*)</url>', $item[$i 1], $url ); eregi('<categorie>(.*)</categorie>', $item[$i 1], $categorie); echo '<a href="' . $url[1] . '">' . $title[1] . '</a> - ' . $categorie[1] . '<br />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175965 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 Can I ask a question here? although i have searched it on google, but i dont understand how they had defined RSS, can anyone explain to me what is the purpose of it? Thanks Ted Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175969 Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 Simple. To provide an easy way to import continually updated content into your site (or, export to sites). To 'syndicate'. Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175975 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 how does it continually updated content on to my site? Thanks Ted Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175979 Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 It depends on the feed. Imagine this. The 'feeder' site publishes an XML file that you pull into your site using the snippet of code. The XML file contains instructions to parse the last 25 tutorials added to their database which is added to daily by various authors, let's say. So, no matter what, each day as long as there are new tutorials published they will be fed to your site and displayed. New content. Simple. Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175985 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 oh, i see, if i display ten most recent tutorials, and i have ten already, what happens when i add one more to the xml? does the 11th one get washed away? Ted Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-175988 Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 You could have the XML set for the last 100 if you want. Just have to make sure you have room for them on your page. The other key is, you can use that same snippet in dozens of locations throughout your site (like category pages) and just have it call a different XML file relative to the topic you've placed it in. Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-176164 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 thanks, i think i sort of understand it better. Link to comment https://forums.phpfreaks.com/topic/36886-does-anyone-have-a-simple-rss-code-that-works/#findComment-176171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.