Proof of Concept: Twitter aggregator for Drupal with Drupal

Happy new year! Oops, already Fabruary...

As I have some time for my last semester in Dublin, I can test some little things I wanted to do.


I have built a little Drupal tweets aggregator, fetching only those that have links embedded (this Twitter search). It stores all these tweets, but as the nodes are not very easy to manipulate for statistics, I decided to make my own module et not use the Aggregator module from Drupal core. Four SQL tables and let's go: storing tweets, links et their authors in a hook_cron() :

  • aggreg_tweets(id, author, text, date)
  • aggreg_authors(id, name)
  • aggreg_links(id, link)
  • aggreg_links_tweets(link, tweet)


Ok, that's good for now, but we have to do something with these tweets... So let's make some hook_menu entries for statistics pages:

  • One for time-related to see when drupalers are tweeting more, so when to watch
  • One for trendings tweets to see what is happening and what is relevant right now

For that I would have been bothered by the nodes: doing some GROUP BY and ROLLUP queries on so many JOIN , no thanks!
Some highcharts.js library to render nice charts, little tables and an ajax query to fetch which tweets are related to a link (to add some context) later and here it is: a nice Twitter aggregator

Twitter bootstrap

This fresh new theme (therefore in dev version) have some bugs due to Drupal integration and licensing issues but there are solved in few changes. It provides some CSS classes to render nice tables and some JS plugins to create modals (I also added bootbox.js for easier handling, thanks to @FGRibreau). It results in a simple & nice interface perfect for proofs of concept or small projects like this one.

Drupal, a real framework

This recipe is prepared in about 350 lines of code thanks to Drupal hooks and methods. Among them I used:

  • hook_menu() & hook_cron()
  • db_merge()
  • variable_get() and variable_set(), just essential
  • l(), truncate_utf8(), theme_table() for rendering
  • curl for HTTP requests

Now I will be able to tweet relevant links about Drupal, so don't hesitate to follow me on Twitter !

Subscribe to RSS - Twitter