Last week at WBR, we re-launched the website for My Chemical Romance. The site’s built on Drupal 6.x and showcases blogs, photos, and tweets directly from the band members.
To aggregate the Twitter feed, we used the FeedAPI module and associated SimplePie parser. Cron runs every 10 minutes to ensure the content stays fresh.
We hit a few bumps getting this all to work.
Feeds rarely updating
Initially, the feeds were scarcely refreshing. The problem was caused by SimplePie doing its own feed caching, with FeedAPI blissfully unaware. To fix this, I wrote a simple patch for parser_simplepie.module (under review as of this writing): http://drupal.org/node/341410
Cron not refreshing feeds
Cron, when invoked from a command-line PHP script, was failing to refresh the feeds. The cause was a default PHP setting of max_execution_time = 0.
FeedAPI uses max_execution_time to calculate its allowed time during a cron run. This value is always set when invoking PHP through the web, but it needs to be explicitly defined in any command line PHP script. This is solved with the following line of code:
ini_set('max_execution_time', 300); // Set to 5 minutes
Cron refresh rate set too high
FeedAPI sets a default cron refresh rate value of 1800 seconds. This prevents cron from refreshing the feeds twice within 30 minutes. For us this was too high (cron runs every 10 minutes). Lowering this to a more reasonable setting did the trick.
feedapi.module (lines 14-15):
// Minimum time that must elapse before a feed can be refreshed again on cron.
define('FEEDAPI_CRON_MIN_REFRESH_TIME', 300);
Everything is now running smoothly!


{ 3 } Comments
I see you guys are using Drupal 6. Was Twitter module (http://drupal.org/project/twitter) a consideration? And if so, why did you decide on FeedAPI instead? Just curious to see if you did any performace testing between the two and what results you may have gotten.
~Jerad
The Twitter module is awesome and we have future plans for it. It adds a Twitter tab on a user’s profile page, making it a great feature for a community-based site.
For the MCR site, we were interested in storing tweets as nodes, something the Twitter module does not do. Thus we used feedapi + feedapi_mapper + cck instead.
Hey there–
I’m doing a pretty similar thing m’self with my new music website. Thx for posting the info.
I’m assuming that you’ve got a specific content type that the tweets are going into, then the twitter feed is just a view in a block on the right, ya?
Are you using panels at all?
Thx,
Craig
Post a Comment