If widgets aren’t enough, then you can always use Twitter’s REST API to build custom functionality.
Drupal has a bunch of contributed modules that make it easy to integrate Twitter into Drupal.
In this article, I’ll show you a few popular modules that can help you add embedded widgets and access Twitter’s API from within Drupal.
The Twitter module, the most popular of the modules, offers API integration with Twitter. If you need to post or import tweets from within Drupal, then this module is for you. It also comes with three sub-modules: Twitter Actions, Twitter Post and Twitter Signin.
The Twitter Actions sub-module integrates Twitter with Trigger (core module) and Rules. This is useful for when you want to automate or send tweets on a specific event.
Twitter Post, once enabled, allows you to post and compose tweet messages directly from the node form. For example, an editor can post a tweet by checking the “Announce this post on Twitter” checkbox when creating an article.
The Twitter Signin sub-module, as you may have guessed, allows Drupal users to register and login using their Twitter account.
Now, if you need to build some custom integration with Twitter then I highly recommend these modules. Not only do you get all of the mentioned sub-modules, but you also get a simple API for posting tweets and more from any custom module.
The Twitter module gives you a lot, but you have to be aware that setting it up isn’t as simple as just installing it. Since Twitter changed their API over to version 1.1 all requests to the API have to be authenticated.
The module is useful for editors because it allows them to add timelines into any Drupal site using a simple interface. It saves them from copying and pasting HTML code, which can be problematic.
If you want to learn about Twitter Block, check out my in-depth tutorial called How to Display Tweets using Embedded Timelines in Drupal 7.
Metatag: Twitter Cards (Metatag)
Twitter cards make it possible to attach rich media to tweets like images, videos and article summaries.
To learn how to setup Twitter cards in Drupal, check out my tutorial called Display Twitter Cards in Drupal Using Meta Tags Module.
Another module worth mentioning is Twitter Pull.
Back before Twitter required all requests to their API be authenticated, this module was great for displaying timelines in Drupal because it didn’t require OAuth or a lengthy setup process. However, the 2.x version of the module now requires the Twitter module because of Twitter’s policy for all requests to be authenticated.
I have not used the latest version of this module, but I want to add it to this list so people are aware of it. I’ve used the older version before and it worked brilliantly.
Extra: Twitter Buttons
Last but not least, modules that add a “Tweet” button to a Drupal page are a dime a dozen. So I’m just going to give you a list of modules, I may miss a few, but here are the main ones:
If you’re looking for an easy way to add embedded widgets into a Drupal website, check and see if a module already exists. If you want to add Twitter cards, use Metatag sub-module instead of adding the meta tags manually. If you need to add a timeline, then use Twitter block instead of dealing with a chunk of HTML code.