5 Days Left to Replace Your Twitter RSS Feed in Drupal

Twitter module - Drupal admin

 
If you haven't heard, Twitter RSS is officially dead on March 5, 2013 (here it is in Twitter-corporate-speak; Mashable translation). If you're using Aggregator to pull a Twitter RSS feed into your Drupal site for pretty stylin', then you have to act now. The process for replacing the RSS feed is annoying, but not impossible. I've done it a few times now.

You actually have a couple different options for doing it. One is to parse the JSON feed. The JSON parsing module in Drupal is beta and in low use, so we're not dabbling with that one right now.

The method we're using is the Twitter module, which in this situation requires the OAuth module. We just replaced the RSS tweet in the footer of http://ActionAgainstHunger.org using this method. It's nice because if you're using a View to display your RSS feed, then the Twitter module will give you a default View to use once you've got OAuth pulling in your Tweets. You can easily build a block or page off that View to match whatever you've got for your Twitter RSS feed now, tweak your CSS as needed, and you're back in business. This module combo is also more powerful than the RSS feed pull. It pulls in hashtags and links better, can pull in user account images, and can be configured to allow users to post to Drupal from Twitter. So, it's not all bad. Setting it up is tedious and takes some time, but once you've done it a couple times, it goes a bit faster.

The biggest problem with this new setup for pulling Tweets into Drupal is that I find the process to be esoteric, mostly on the Twitter end (big surprise). Basically, you set up some OAuth keys in Twitter that allow authenticated communication between your Drupal site and Twitter, not unlike how you have to set up keys on Mollom's site and copy them into your Drupal site for Mollom to work. Then, you can pull in Tweets on cron runs just like you did with RSS. I'll walk you through the steps. If you see missing steps or have tips to add, please feel free to add them in the comments. Note: these instructions are for Drupal 7. If you do a D6 RSS/OAuth swap out, please let us know how it goes in the comments. Official Twitter module install documentation page is here, but I found it confusing a bit out of date, so hopefully this will help.

  1. Use Drush to download and enable the OAuth and Twitter modules, or download, install, and enable them manually. A bunch of sub-modules will come down. You only need to enable oauth_common and twitter for a display of tweets via Views.
  2. When these puppies are enabled, go to admin/config/services/twitter/settings in your site. See that Callback URL? Copy that to your clipboard for your journey into Twitterland. You'll need it.
  3. Click on the register your application link in the settings page. It'll take you to https://dev.twitter.com/apps/new. Make sure you're logged in as your main Twitter user when you do this.
  4. In the "Create an application" form, name and describe this instance of OAuth keys. Doesn't much matter what you call it. Put your main site URL in the website field. You can add more domains if you need to after you're set up.
  5. Paste that callback URL into the callback URL field!
  6. Check the box that you accept their corporate blah blah blah (after reading them, of course! ;) ). Good luck with your CAPTCHA. Then submit the form.
  7. You should land on a summary page for your new application. There are tabs. You can poke around in there and add more domains if needed. Most importantly, on that main tab, click the blue Create My Access Token button at the bottom of the screen.
  8. Copy the "Consumer Key" from Twitter into the "OAuth Consumer Key" field in your Drupal Twitter config page. Same with the "Consumer Secret" (SHH! ;) ). Save this config in your Drupal site. (Now you're probably like... really, there's more to do?! But you're almost there!)
  9. Now click on the "Twitter" tab in your Drupal site, so you're at admin/config/services/twitter. Click on the big honkin' button that says Go to Twitter to add an authenticated account. That'll take you to Twitter. Make sure you're logged in as the main account you want to associate with this site when you click to authorize it.
  10. You should now get brought back to your Twitter settings tab on your Drupal site and see your Twitter user icon there. Check the box under "Tweets" and hit "Save Changes".
  11. You now have to run cron to pull tweets, just like with ye olden RSS feeds. There's a link on that page to run cron, or run it however you'd like. It can take a minute or two.
  12. Now, if you click on the "View" link under your "Tweets" check box, you should get a View page of your tweets. Here's the one I just made on my personal site while writing this blog post: http://johannabates.com/tweets/hanabel
  13. You're pretty much done! That's page of Tweets is a View. You can build more page displays and blocks off it, clone it, alter what fields are displayed and how they're displayed, and theme it however you want. You'll also notice in your Twitter settings admin tab that you can add more authenticated accounts, or add public accounts that aren't authenticated. It took a while, but now you've got some fun options to explore.

Tip: If you have trouble getting the OAuth connection working properly, try generating new keys, and remember to replace them in your Twitter admin config on your Drupal site. Also make sure you're using the callback URL that the Twitter module provides you. That's important.

Hey, do you see that DEPRECATED WIDGET that we're using on this very site in the right column? Twitter could turn that off *any minute*. I've got everything set up to replace it on this site. Cobbler's children. No shoes. I just have to make some time to theme our new tweets block. Hah.

Good luck and feel free to put questions in the comments.