IKA Works Laboratory equipment - Bollywood India forum movie reviews - Expekt bonuses - Free Advertising - Anime

PDA

View Full Version : How to display rss feed in my site?


PinoyIto
Sep 10th 2005, 8:15 pm
I am just wondering how those site like http://www.topix.net/ display feed from diffirent news site. What kind of script they are using? Is there a free script out there?

Thanks

pcdoc
Sep 11th 2005, 3:28 am
I've been using http://www.feeddigest.com/ with good results.

WhatiFind
Sep 11th 2005, 4:35 am
Check this thread: http://forums.digitalpoint.com/showthread.php?t=7354, easy to setup using php

king_cobra
Sep 11th 2005, 4:52 am
if u r looking for custom coding in php i can help you. see my website. it uses feeds. but let me not stick to my service advertisement.

feed parsing can be done by php libraries like magpress. or parsing the file directly through file handling routines (bit tough). you can get it done in no time if u know how to.

hedir
Sep 12th 2005, 8:23 pm
If you want it easy , check out http://jade.mcli.dist.maricopa.edu/feed/index.php?s=build

badhairdude
Sep 16th 2005, 8:52 pm
oh nice, i always wanted to try this, I heard it generates more traffic

mikelbeck
Sep 17th 2005, 1:57 pm
You can do this with Magpie, pretty simple.

Here's what you can do - keep in mind this is off the top of my head, there may be a mistake or two in here.

- Download Magpie from http://magpierss.sourceforge.net, unpack it to a directory off your root called "rss".
- Create a directory off your root called "cache", chmod it to 777.

Simple PHP code:


<?php
require_once('rss/rss_fetch.inc');

$news_feed = '';

error_reporting(E_ERROR);

$rss = fetch_rss("http://www.url-of-the-rss-feed.com");
$items = array_slice($rss->items, 0);
foreach ($items as $item )
{
$news_feed .= '<a href="' . $item['link'] . '" target=_blank>' . $item['title'] . '</a><br />' . $item['summary'] . '<br />';
}
?>


Sorry for the crappy code. ;-)

Your rss data will be formatted and placed in the variable "$news_feed". You can do this multiple times for different feeds.

Also, since Magpie caches the data, you won't be hammering the feed source every time your page is loaded.

I use a similar method for getting data from a bunch of sources, a random selection of them are displayed on each page on the bottom of this site: www.TheSEOKing.com. Everything that's in the cache is displayed on this page: www.theseoking.com/news.php

eiso
Sep 18th 2005, 9:47 am
CarP worked very well for me.

yulia
Sep 23rd 2005, 8:36 am
Cool... it works for me..

Thanks for the script :)

jim
Nov 27th 2005, 1:53 am
I tried adding a Google news feed to my site, bu there's some problem with it URL. For example http://www.eslgo.com/travel/ works fine with but when I tried changing the url and putting on my MT 2.64 blog, it no longer worked. (the new url was http://news.google.com/news?hl=en&ned=us&ie=UTF-8&q=car+insurance&output=rss)

So my question is can someone help me get this Google news rss going on my MT 2.64 blog?

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://news.google.com/news?hl=en&ned=us&ie=UTF-8&q=car+insurance&output=rss","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

jawinn
Nov 28th 2005, 9:02 am
mambo's software works great for me; but it only supports RSS feeds.