Main menu

"Goodbye, Jean-Luc, I'm gonna miss you. You had such potential. But then again, all good things must come to an end."
- Q, Star Trek: TNG

Integrating Twitter into Drupal 7 ... without RSS

by Ken Newquist / September 25, 2012

One of my goals for the Nuketown 7 redesign project was to tightly integrate social media options into it. In particular I wanted to be able to capture all of that microcontent -- the quick movie and book reviews, the game news, the retweets -- that the site currently misses and incorporate it into the design. The key here isn't that I'm simply trying to post tweets about new articles; I want to make microcontent an integral part of the site.

To do that the tweets needed to be captured as nodes, which would then allow me to manipulate and display them however I see fit. I accomplished this by creating a "microcontent" content type and then setting up the Feeds module to import tweets from my NuketownSF account via RSS.

Naturally once I got this working Twitter deprecated RSS feeds. As of March 2013, you'll no longer be able to use them ... and Nuketown's microcontent import would cease to function.

Fortunately I have a Plan B: the Twitter module. When I started building out Nuketown7 I'd considered using this module, but it had two drawbacks:

  1. When it posted to Twitter it used the node's title, rather than the body. Given that I'd planned on having the meat of the tweet live in the body, this was a problem.
  2. When it imports from Twitter, the tweets are associated with the user, and are stored in a module-specific table. They aren't nodes, and they're hard to get at using views.

Since then I've built out the microcontent nodes, and discovered that they worked best when the body of the tweet actually appears in the title AND the body. It solves a number of display and theming issues, and it's ultimately how I got the Feeds importer to work.

Revisiting the Twitter module I found that I could use it in tandem with the microsite format to post updates to Twitter. Better yet I could use this to post microcontent or articles, which means there can be a constant stream of updates of Nuketown.

As I worked through this option, I found a lot of advantages. I can much more easily categorize and tag microcontent this way; the Nuketown 7 scope called this microcontent "tachyons" and they were incorporated into the site's larger taxonomy. This allows the microcontent to appear along side relevant articles on category pages (e.g. music, games, etc.). I'd thought about doing the same by parsing Twitter hashtags into Drupal tags as part of the Feeds import, but this allows me to tag things when I create the content.

There is a downside in that there will inevitably be content in the NuketownSF feed that doesn't make it into the site, such as replies to readers, unless I consciously go back and originate the tweet in Nuketown. The benefit of having the content originate in Nuketown outweighs that however.