Drupal 7: Importing Tweets into Drupal using the Twitter Module

Why would you want to import tweets into a Drupal site?  For one, I want to own the content I create.  Unlike other social media sites, Twitter allows great access to the content I create on their platform.  Through their API, I can access all of my Tweets and Mentions for archiving and displaying on my own site.

I have had a couple of instances with clients where the archiving of Tweets came in handy.  One when a Twitter account was hacked, and one when someone said something that wasn't supposed to be said.  At the very least, it is an offsite backup of your content at Twitter, and that is never a bad thing.

I have used this module for building aggregated content.  If you have a site that is surrounded by topics, you can build lists of Twitter accounts or #hashtags.  Imagine if you were running a Drupal Camp, you could build a feed of all of the speakers and sponsors, or a feed of the camp's #hashtag, or both!

You could also build a Twitter feed of only your community.  This module allows each and every Drupal user account to associate with one or many twitter accounts.  The users just need to authorize themselves.  The possibilities seem endless.

OK, so on with the good stuff.  Importing Tweets into your Drupal 7 site is very quick and easy using the Drupal Twitter Module

  1. Installing Twitter for Drupal 7
  2. Install OAuth Module
    drush dl -y oauth
  3. Enable OAuth Module
    drush en -y oauth
  4. Install Twitter Module
    drush dl -y twitter
  5. Enable Twitter Module
    drush en -y twitter
  6. Configure each module's permissions at /admin/people/permissions
  7. Configure Twitter settings in Drupal here /admin/config/services/twitter/settings
  8. Create a Twitter Application
    Twitter App Setup
  9. Enter your "Consumer Key (API Key)" and "Consumer Secret (API Secret)" into the Configuration settings in Drupal.
  10. Go to the Main Twitter Module page /admin/config/services/twitter and add associate one or many Twitter account(s) to your Drupal account.
  11. Select what you want to import, Tweets, Mentions, or both.
    Drupal Twitter Settings

Tweets will be imported on cron run, and are available to use in views.  By default, a view is created that builds 2 different pages and a block, but you can also create your own.  I always clone and disable the default view, so I can work on my own view without fear of breaking everything.  This also adds the ability for me to export it to code using Features.

  • The Drupal Twitter Module also has some great additional features including:
  • Posting to personal Twitter and/or sitewide Twitter accounts
  • Drupal Login using Twitte credentials
  • Text formats that convert @usernames and #hashtags to links to Twitter.com

What are some other ways you have used Twitter and Drupal together?