Fixing the Twitter module in Drupal

By donmc, 19 September, 2010
The Twitter module for Drupal now needs to use the new OAuth module for authentication in Twitter.  This has broken many web sites.  I use this feature on this site to automatically post a tweet whenever I add a new blog entry.  I use a global account in Drupal to do it, rather than individual Twitter accounts for each drupal user. In order to get the Twitter module to work now, you'll need to do the following things (note that this sequence is for a single global Twitter account for all users wanting to have their tweets posted by the Twitter Module)

Steps to take:

  1. Upgrade the Twitter Module from 6.x-2.6 to 6.x-3.0-beta2 or better
  2. Install OAuth 2.0 (OAuth 3.0 doesn't work with Twitter 6.x-3.0-beta2) - in the drupal Oauth settings be sure to set OAuth cryptography as "HMAC-SHA1" and not Plain Text or RSA.
  3. As ADMIN (User 1) Run update.php -> this will update the database to support the new version of the twitter module
  4. Register your application with twitter: In your Twitter application settings ensure you have "Application Type" set as Browser and the "Callback URL" should be http://yoursite.com/twitter/oauth
  5. Set up the Twitter Module on your website (at http://www.yoursite.com/admin/settings/twitter ) to use the registered Consumer Tokens: "Consumer Key" & "Consumer Secret"
  6. Login as the admin user whose twitter account has been setup
  7. Go to My accounts -> Edit -> Twitter Accounts (click on the "Make Global" link to the right for the global user you assign)
You should now be able to post to twitter using OAuth. Twitter should also show that the tweet has been made from the global Twitter user.