Twitter Post not working, need to use OAuth with Twitter 6.x-3.0-beta2

How to get Drupal to post updates to Twitter again (or How to Fix the Twitter module in Drupal)  

 

Recently Twitter changed its app policy to require the use of something called Oauth to connect to its servers.  This is actually a good thing because instead of using someone's Twitter username and password to gain access to applications, it instead asks for an OAuth key and OAuth secret to connect to the Twitter service.  This system should be far more difficult to circumvent for any applications that may be trying to steal your Twitter credentials.

The downside to this is that it caused many sites using the Twitter module for Drupal to lose their ability to submit updates to their Twitter account.  I use this module to automatically update my Twitter profile with a link back to my new blog posts.  After the OAuth changes occurred, I had been forced to manually post updates to Twitter.  Thanks to the Drupal community, however, I was able to get it working again.  This is how (these directions are for Drupal version 6):

First you need to get an updated version of the Twitter module, if you have not already done so.  The version I obtained was 6.x-3.0-beta2 which can be downloaded from here:  http://drupal.org/project/twitter (Warning:  many security-minded Drupal developers strongly discourage the use of Beta modules on production websites for security reasons - this is probably a good idea if your site allows users to freely sign up and create their own accounts without approval - proceed at your own risk).

You also need to get and install the OAuth module from here: http://drupal.org/project/oauth - but make sure you do not install the 3.0 version - Drupal's Twitter module will only work with OAuth version 2.0 (or more specifically I obtained version 2.02).

If you accidentally get version 3.0 (like I did), you will need to uninstall the OAuth 3.0 module and delete it from your modules folder before installing the correct version.

Go to Administer > Site Building > Modules and enable OAuth and Twitter signin (if you are setting up Twitter for the first time you should also enable Twitter, Twitter actions and Twitter post, Twitter actions is only necessary if you intend to create rules regarding Twitter).

Once both modules are installed, access the Twitter configuration page (Administer > Site configuration > Twitter setup) and click on the "register your application" link to take you to Twitter to in order to register your website as a browser application.  Note the Callback URL - it should look like "http://<your site address>/twitter/oauth - you will need this for the application registration.

You will need to sign in with your Twitter user name and password, and you will be taken to the registration page.  On this page make sure you fill out the appropriate information for your website.  Select Browser under Application type.  Enter the Callback URL you noted in the previous step, set access to Read and Write, and select Yes use Twitter for Login.

Twitter will provide you with an OAuth consumer key and a consumer secret code after you submit your registration form.  Return to Administer > Site configuration > Twitter setup on your website and place the key and the secret code in the appropriate fields. You may also want to make changes to the setup under the Post and Sign-In tabs to suit your preferences.

Finally, you will want to sign into the user account you wish to be able to post to Twitter on your Drupal site.  Edit your account, and select Twitter accounts.  If you still have a Twitter account listed here, place a check mark into the Delete box and then click Save changes to remove it.  Then click Add account, and you should be prompted to connect to your Twitter profile.  Once you have completed authorizing your website Twitter application, you should be returned back to your account page and you should see your Twitter name and avatar.

Once this is done, you will be able to update your Twitter account automagically from Drupal.  Sweet!

Subject: