StatsBurner v2.3
This PHP class is a wrapper for the Feedburner Awareness API. It grabs your circulation hits, views, stats and averages over a given period of time. Can be customized to grab data from certain dates, date ranges and discrete dates.
Recent Thoughts
- Twitter feed is currently unavailable. View my Twitter
Manual v1.x : Table of Contents
Feed Aggregator v1.4 (Log)
Uploaded: 10/03/2009
Requires: PHP 5, CakePHP 1.2
Tested On: PHP 5.2.5, CakePHP 1.2.5
View Manual:
Feed Aggregator
Package: Component
Category: CakePHP
Views: 1,188
A CakePHP Component that will take a list of feeds and aggregate them into a single array based on their timestamp.
Class Features:
Class Features:
- Supports RSS 2.0, RSS 1.0 (RDF) and Atom feed types
- Can support as many feeds as you wish
- Separates feeds into groups so you can add accordingly and not conflict
- Uses the HttpSocket and XML libraries to parse the feeds
- Built in cache support (with a little configuration)
- Has a max return limit to cut down the returned arrays size
Top
1 - Installation
To use the component, you would add it to the $components array of the controller you wish to use it in. I suggest you only place it in controllers that will utilize it, and not in the AppController.
Cacheing Results
This configuration should be automatically called when the component is used, if it does not you can do the following. You would place the code below in your app/config/core.php at the very bottom alongside the rest of your cache settings. Secondly, make sure $cache equals true in the component.
var $components = array('FeedAggregator');
Cacheing Results
This configuration should be automatically called when the component is used, if it does not you can do the following. You would place the code below in your app/config/core.php at the very bottom alongside the rest of your cache settings. Secondly, make sure $cache equals true in the component.
Cache::config('feeds', array( 'engine' => 'File', 'serialize' => true, 'prefix' => '' ));
Top
2 - Configuration
Like any other component, the Feed Aggregator component has a few variables that you can set in your controller's beforeFilter(), they are.
Item Count
This is a fallback limitation that is set in-case the aggregates() limit fails for some reason. Usually you do not need to change this value.
Grab Description
Most of the time you do not need the description of the feed items, simply the title, date and permalink. By default this value is turned off, but you can set it to true to grab the description from the items.
Grab Additional Elements
By default the script will grab the link, title and date elements. If you wish to grab more elements, add the names of the elements into this property.
Caching
If set to true your feeds will be cached to your cache folder. If set to true, you must apply the "feeds" configuration. By default this feature is turned off.
Cache Expiration
How long should your feeds be cached for? Default is for one hour. Its best to use the shorthand notation like "+1 hour".
Item Count
This is a fallback limitation that is set in-case the aggregates() limit fails for some reason. Usually you do not need to change this value.
$this->FeedAggregator->returnItemCount = 10;
Grab Description
Most of the time you do not need the description of the feed items, simply the title, date and permalink. By default this value is turned off, but you can set it to true to grab the description from the items.
$this->FeedAggregator->grabDescription = true;
Grab Additional Elements
By default the script will grab the link, title and date elements. If you wish to grab more elements, add the names of the elements into this property.
$this->FeedAggregator->grabElements = array('author');
Caching
If set to true your feeds will be cached to your cache folder. If set to true, you must apply the "feeds" configuration. By default this feature is turned off.
$this->FeedAggregator->cache = true;
Cache Expiration
How long should your feeds be cached for? Default is for one hour. Its best to use the shorthand notation like "+1 hour".
$this->FeedAggregator->expires = '+2 hours';
Top
Read the whole documentation? Download the script now and try it yourself! Return to the Top
3 - Usage
The aggregator is extremely simple to use, all you have to do is add feeds to the list with addFeed() and then parse them with aggregate(). For the example below, I will showcase a trimmed down version of the same code I used for the homepage of GameSync. Another thing to note is that feeds can be separated into groups so that you don't have different types/categories of feeds in the same timeline.
The addFeed() method takes two arguments, the first is the group you wish to place the feeds into, and the second is an array consisting of the feeds to be added. The feeds being added should be an array with the index being the source name and the value being the feed URL.
The aggregate() method also takes two arguments, the first is the group you wish to be parsed and the second is how many items should be returned. If no item count is present, it the count will fall back to $returnItemCount. This method will return a dimensional array with the latest items from all combined feeds.
function index() { $this->pageTitle = 'Homepage'; $this->FeedAggregator->addFeed('industry', array('IGN' => 'http://feeds.ign.com/ignfeeds/games/')); $this->FeedAggregator->addFeed('league', array('GotFrag' => 'http://www.gotfrag.com/portal/xact/xml/?f=stories&a=any')); $this->set('industry', $this->FeedAggregator->aggregate('industry', 10)); $this->set('league', $this->FeedAggregator->aggregate('league', 10)); }
The addFeed() method takes two arguments, the first is the group you wish to place the feeds into, and the second is an array consisting of the feeds to be added. The feeds being added should be an array with the index being the source name and the value being the feed URL.
The aggregate() method also takes two arguments, the first is the group you wish to be parsed and the second is how many items should be returned. If no item count is present, it the count will fall back to $returnItemCount. This method will return a dimensional array with the latest items from all combined feeds.