Skip to content

aggrss, an rss aggregator


[updated] Uses the lastRSS library tolastrss_button.gif
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:

  1. Create the cache directory – wp-content/aggrss-cache – and make it world writeable (chmod 777)
  2. create subdir wp-content/plugins/lastRSS
  3. 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)
  4. Save aggrss.php.txt (4.4 KiB, 1,363 downloads) as aggrss.php in your wp-content/plugins directory
  5. 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 -->";
    }
}

Demo:
http://soderlind.no/dilbert/

66 Comments

  1. 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

    Posted on 28-Sep-04 at 18:03 | Permalink
  2. PS

    My fault, it should be Get (with a capital G), I’ve fixed it in the zip file

    Posted on 28-Sep-04 at 21:00 | Permalink
  3. andy

    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.

    Posted on 17-Oct-04 at 18:04 | Permalink
  4. 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?~

    Posted on 27-Oct-04 at 21:09 | Permalink
  5. 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

    Posted on 06-Nov-04 at 1:16 | Permalink
  6. Spikehead

    Great plugin! One question. Is it possible to display more than one feed? Thanks!

    Posted on 08-Nov-04 at 3:58 | Permalink
  7. Will

    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?

    Posted on 08-Nov-04 at 17:09 | Permalink
  8. PS

    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 -->";
        }
    }
    
    Posted on 08-Nov-04 at 22:13 | Permalink
  9. 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.

    Posted on 21-Nov-04 at 8:29 | Permalink
  10. PS

    Prentiss R: I’ve fixed the link, you should use this one.

    Posted on 21-Nov-04 at 15:55 | Permalink
  11. 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.

    Posted on 21-Nov-04 at 19:43 | Permalink
  12. Alaska_Ken

    I’m also getting the “Call to undefined function: get()” error. If you find a solution please let us know.

    Posted on 29-Nov-04 at 11:34 | Permalink
  13. 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!!

    Posted on 02-Dec-04 at 18:47 | Permalink
  14. 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 –>“;
    }
    }
    ?>

    Posted on 02-Dec-04 at 18:50 | Permalink

  15. 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 –>“;
    }
    }

    Posted on 02-Dec-04 at 18:52 | Permalink
  16. PS

    Ryan: Not sure what you mean, does it work or not ? :)

    Posted on 03-Dec-04 at 14:29 | Permalink
  17. essdsm

    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

    Posted on 08-Dec-04 at 19:33 | Permalink
  18. PS

    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.

    Posted on 09-Dec-04 at 3:20 | Permalink
  19. Clark

    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?

    Posted on 10-Dec-04 at 2:54 | Permalink
  20. 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.

    Posted on 10-Dec-04 at 17:34 | Permalink
  21. Anon

    This is cool, but I think there should be instructions on how to implement it. I have no idea how to do this.

    Posted on 11-Dec-04 at 1:14 | Permalink
  22. PS

    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.

    Posted on 11-Dec-04 at 22:22 | Permalink
  23. PS

    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)

    Posted on 11-Dec-04 at 22:31 | Permalink
  24. Clark

    Thanks! Even one with a 3YO’s coding ability (ME) can figure it now.

    Posted on 11-Dec-04 at 22:31 | Permalink
  25. Thanks! This makes my Gallery CVS checkins page, and my Audioscrobbler songs display nicely :-)

    Posted on 04-Jan-05 at 23:57 | Permalink
  26. 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!

    Posted on 06-Jan-05 at 17:45 | Permalink
  27. 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?

    Posted on 07-Jan-05 at 5:13 | Permalink
  28. 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!

    Posted on 02-Feb-05 at 7:33 | Permalink
  29. 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 !!!

    Posted on 18-Feb-05 at 0:29 | Permalink
  30. 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 = ‘ ‘;

    Posted on 18-Feb-05 at 1:37 | Permalink
  31. PS

    Thank you Jonas for reporting this

    Posted on 18-Feb-05 at 1:45 | Permalink
  32. 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.

    Posted on 27-Feb-05 at 9:11 | Permalink
  33. PS

    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.

    Posted on 27-Feb-05 at 20:21 | Permalink
  34. 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']

    Posted on 15-Mar-05 at 23:36 | Permalink
  35. 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.

    Posted on 23-Mar-05 at 21:48 | Permalink
  36. I’ve followed all the examples but I still get an error of not being able to reach the RSS feed.

    Posted on 15-May-05 at 2:27 | Permalink
  37. Post a Comment

    Your email is never published nor shared. Required fields are marked *
    *
    *
Rodney's 404 Handler Plugin plugged in.