[updated] Uses the lastRSS library to![]()
aggregate RSS feeds.
lastRSS (and this plugin) gives you:
- All RSS versions supported (0.9, 1.0 and 2.0)
- Regullar expression parsing (very quick)
- Returns an associative array with RSS fields
- RSS tags not present in RSS are also not present in result now
- Transparent cache
- Character encoding conversion (all encodings supported by iconv library)
lastRSS is free open-source software (GNU/GPL), this plugin has a BSD license
Instructions:
- Create the cache directory – wp-content/aggrss-cache – and make it world writeable (chmod 777)
- create subdir wp-content/plugins/lastRSS
- Extract lastRSS.zip and save lastRSS.php in wp-content/plugins/lastRSS
local copy: lastRSS.0.9.1.zip (2.9 KiB, 2,014 downloads) - Save aggrss.php.txt (4.4 KiB, 1,363 downloads) as aggrss.php in your wp-content/plugins directory
- Activate the plugin from the Plugins page (re-activate (deactivate + activate) if you are upgrading aggrss)
Use:
$rs = aggrss($rssurl,$striptags=false,$num=0); /* $rssurl, url to the rss optional parameters: $striptags, if true all html tags will be remove from decriptions. $num, defines the number of records you want to display, $num=0 equals all available */
aggrss returns the rss content as an associative array with RSS fields, see sample below.
if ($rs = aggrss('http://soderlind.no/feed/rss2/')) {
// dump the structure
//echo "<pre>";
//print_r($rs);
//echo "</pre>";
echo "<h2><a xhref='" . $rs[link] . "'>" . $rs[title] . "</a></h2>";
echo $rs[description] . "<br />";
foreach ($rs['items'] as $item) {
echo "<p><a xhref='" .$item['link']. "'>" . $item['title'] . "</a><br />" .html_entity_decode($item['description']). "</p>";
}
if ($rs['items_count'] < = 0) {
echo "Sorry, no items found in the RSS file
"; }
} else {
echo "<!-- It's not possible to reach RSS file -->";
}
}
66 Comments
This looks really cool. I’m just a little confused about implementing it. After I enable the plugin, what code do i use to put this in my index.php file? I tried using your example, but generates this error: Fatal error: Call to undefined function: get() in /path/to/wp-content/plugins/aggrss.php on line 119
My fault, it should be Get (with a capital G), I’ve fixed it in the zip file
This is *nice*! Thank you… it’s exactl what I was looking for. And it’s done just so incredibly simply…. graceful. Yay!
Just one thing for noobs like me and people using a GUI FTP client:
Rather than saying “Extract aggress.zip in wp-content/plugins,” you may want to note that the *contents* of the aggrss folder that is created when you unzip the file is what you want to upload to the plugins directory.
i still get /path/to/wp-content/plugins/aggrss.php on line 119 error in the latest zip file~ help~
what happen to the get function? i cant get it to work?~
If you’re using older versions of PHP, you may get fatal errors mentioning html_entity_uncode. The solution is here: http://pear.php.net/manual/en/package.php.php-compat.intro.php
Great plugin! One question. Is it possible to display more than one feed? Thanks!
Trevor: I had a look at your link (which Per, the author, kindly pointed me to) but unfortunately I’m still at a loss. Like the others, I’m getting “Call to undefined function: get()” on line 119; I just can’t work out why. Any ideas?
Spikehead: You could do this:
$feeds = array ("http://soderlind.no/feed/rss2/", "http://slashdot.org/slashdot.rdf", "http://dwlt.net/tapestry/dilbert.rdf"); foreach ($feeds as $feed) { if ($rs = aggrss($feed,false,1)) { echo "<h2><a href='" . $rs[link] . "'>" . $rs[title] . "</a></h2>n"; echo $rs[description] . "<br />n"; foreach ($rs['items'] as $item) { echo "<p><a href='" .$item['link']. "'>" . $item['title'] . "</a><br/>" .html_entity_decode($item['description']). "</p>n"; } if ($rs['items_count'] <= 0) { echo "Sorry, no items found in the RSS file
"; }
}
else {
echo "<!-- Sorry: It's not possible to reach RSS file -->";
}
}
I’m getting a 404 Not Found from the aggrss.php.txt URL you give:
http://soderlind.no/download/aggrss.php.txt
Is it still available somewhere? Thanks.
Prentiss R: I’ve fixed the link, you should use this one.
Thanks! I’m impressed — this beats some WordPress- and del.icio.us-specific plugins I’ve tried, although I guess those are more usable by people who don’t know PHP.
I’m also getting the “Call to undefined function: get()” error. If you find a solution please let us know.
I tried to install this and then also pased this code in the index.php page… all I get is a blank page with a header…. help!!
ooops…
< ?php
$feeds = array ("http://soderlind.no/feed/rss2/", "http://slashdot.org/slashdot.rdf", "http://dwlt.net/tapestry/dilbert.rdf");
foreach ($feeds as $feed) {
if ($rs = aggrss($feed,false,1)) {
echo "
” . $rs['title'] . “n”;
echo $rs['description'] . “
n”;
foreach ($rs['items'] as $item) {
echo “
” . $item['title'] . “
” .html_entity_decode($item['description']). “
n”;
"; }
}
if ($rs['items_count'] < = 0) { echo "Sorry, no items found in the RSS file
}
else {
echo "< !– Sorry: It’s not possible to reach RSS file –>“;
}
}
?>
I”ll get it right here….
$feeds = array (“http://soderlind.no/feed/rss2/”, “http://slashdot.org/slashdot.rdf”, “http://dwlt.net/tapestry/dilbert.rdf”);
foreach ($feeds as $feed) {
if ($rs = aggrss($feed,false,1)) {
echo “
” . $rs['title'] . “
n”;
echo $rs['description'] . “
n”;
foreach ($rs['items'] as $item) {
echo “
” . $item['title'] . “
” .html_entity_decode($item['description']). “
n”;
"; }
}
if ($rs['items_count'] < = 0) { echo "Sorry, no items found in the RSS file
}
else {
echo "< !– Sorry: It’s not possible to reach RSS file –>“;
}
}
Ryan: Not sure what you mean, does it work or not ?
Nice looking aggregator but is there any chance of getting proxy configuration? I have to work behind a university firewall and feeds from beyond the intranet just don’t make it.
Many thanks
aggrss will support proxies as soon as lastRSS supports it. You’ll have to ask Vojtech Semecky (author of lastRSS) for when he plans to do this.
Implimentation for Dummies!
I’m not sure the exact way to place the code into my WP. Talk to me like I’m a 3 year old, coz most of them have more sense than me! What exact code to I place exactly where, with what exact tags?
I hade a problem with the RSS feed containing double-quotes in the description and that did not work well with the html_entity_decode() function. The solution was quite simple though:
I changed: html_entity_decode($item['description'])
to: html_entity_decode($item['description'], ENT_NOQUOTES)
That solved my problems.
This is cool, but I think there should be instructions on how to implement it. I have no idea how to do this.
Clark and Anon: You’ll find a sample with source at http://soderlind.no/aggrss-demo.php
Hopefully this sample combined with the installation information i enough information to get your implementation running.
eric, hisyam et. al:
I think I found the reason you get the “Call to undefined function: get()” error (got it myself)
You have to include <?php wp_head(); ?> in the header for the plugin to work (see this sample)
Thanks! Even one with a 3YO’s coding ability (ME) can figure it now.
Thanks! This makes my Gallery CVS checkins page, and my Audioscrobbler songs display nicely
I’m very happily using aggrss in a WP blog but I’m now trying to run it in a non-WP environment. At first it looked like aggrss and lastRSS don’t really rely on much infrastructure from WP to work, but now I’ve hit the “undefined get()” problem:
Fatal error: Call to undefined function: get() in /foo/bar/aggrss/aggrss.php on line 128
I can’t just call wp_head() as suggested above because that would require a whole mess of WP functions. Reading the code I can’t figure out [a] what the line in aggrss.php has to do with a missing get() function or [b] exactly what a call to wp_head() would accomplish.
The problematic line 128 is just:
if ($aggr = $lastRSS->Get($rssurl)) …
Why should PHP report the problem as a missing get() function in aggrss.php instead of something deeper in the bowels of lastRSS?
And a call to wp_head() evaluates to apply_filters(‘wp_head’, ”) which gets me into a twisty maze of WP internals that I don’t begin to understand (what are WP filters, anyway?).
So… Anybody have any ideas? It seems to me that aggrss would have an even broader range of potential applications if it could be cut loose from a dependancy on WP. Thanks for your suggestions!
Okay, I think I’ve got it. I’m able to invoke aggrss and lastRSS from a non-WordPress environment as follows.
I have a file wp-borrowings.php (lovely name, I know) that contains just:
< ?
define('ABSPATH', dirname(__FILE__).'/');
function add_filter() {
// no-op placeholder function
return true;
}
function get_settings() {
// no-op placeholder function
return '';
}
function trailingslashit($string) {
if ( '/' != substr($string, -1)) {
$string .= '/';
}
return $string;
}
?>
And I set up the necessary initializations in my non-WP index.php file as follows:
require “aggrss/wp-borrowings.php”;
require “aggrss/lastRSS/lastRSS.php”;
require “aggrss/aggrss.php”;
initAggrss();
Since the dependence on WP is so minimal, maybe a future release of aggrss could remove them entirely?
Thanks for the plugin! Worked like a charm for my forums, I am also trying to impliment it for my gallery feed as well. Gallery uses 2.0 and with the script you have it only parses the text. Can you show me how I can have it display linkable thumbnails as well?
Thank you for your time!
HI ! I am doing some Ebay2Rss stuff with your greart script, Using the latest WP1.5 I get
Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in D:\WebSites\getaccess\ploeck\wp-content\plugins\lastRSS\lastRSS.php on line 159
Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in D:\WebSites\getaccess\ploeck\wp-content\plugins\lastRSS\lastRSS.php on line 201
with your demo script, all settings are in default mode…
Any ideas are appreciated , Googling and Wordpress forums yield nothing THX !!!
Sorry for double post, please delete.
A friend of mine solved my issue, it s PHP5 related, in PHP 5 the string lastBuildDate delivers nothing which is not allowed under PHP5. In order to deliver an empty result it has to be ‘ ‘
so in lastRSS.php it reads and works for me
//after line 156
if ($temp != ”) $result[$channeltag] = $temp; // Set only if not empty
)
//now there is
if ($result['lastBuildDate'] == ”) {
$dummytemp = ‘ ‘;
}
// Ende eingefügt.
if ($this->date_format != ” && ($timestamp = strtotime($dummytemp)) !==-1) {
// convert lastBuildDate to specified date format
$result['lastBuildDate'] = date($this->date_format, $timestamp);
}
And later….
// Strip HTML tags and other bullshit from TITLE
if ($this->stripHTML && $result['items'][$i]['title'])
$result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));
// If date_format is specified and pubDate is valid
// Eigefügt von Guido Walter
//Reason Line 160
if ($result['items'][$i]['pubDate'] == ”) {
$dummyresult = ‘ ‘;
Thank you Jonas for reporting this
This is great, Per!
I’m not seeing anything in my aggrss-cache folder, though. I checked perms, and they should be okay. Not a huge problem at the moment (I’m grabbing feeds on my own server to display as a sidebar) but I’m going to want to use some external feeds soon.
Michael, it’s my fault you don’t see anything in your cache. I did som testing and forgot to update the plugin.
this turns caching off:
$lastRSS->cache_dir = ”; /* RSSCACHE_PATH; */
change this to:
$lastRSS->cache_dir = RSSCACHE_PATH;
or download the plugin again. Thank you for reporting this.
Great plugin, just what I need, I created a new page called, RSS feeds, gave it a new template instead of changing index.php and I’m getting the following page output:
if ($rs = aggrss(‘http://dwlt.net/tapestry/dilbert.rdf’,false,1)) { // dump the structure //echo ”
“;
//print_r($rs);
//echo ”
“; echo ”
” . $rs[title] . ”
“; echo $rs[description] . ”
“; foreach ($rs['items'] as $item) { echo ”
” . $item['title'] . ”
” .html_entity_decode($item['description']). ”
“; } if ($rs['items_count']
I’m bit of a php novice here. I’m trying to customize the output. How do I get the titles bulleted (tried list tags, didnt work)? Also, is there some way just to list the dateofthe post, not the title.
thanks in advance.
I’ve followed all the examples but I still get an error of not being able to reach the RSS feed.
Post a Comment