FREE Drupal 8 Site Building Course (over 4 hours of video)

4 Modules That Help you Integrate your Drupal Site with Twitter

When it comes to embeddable widgets, Twitter has a lot of options: timelines, tweets and buttons.

For instance, If you need to display a timeline on a website then use an embedded timeline. The same goes for tweets; if you want to display inline tweets, then display them using an embedded tweet.

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.

Twitter

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.

Fig 1.0

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.

Fig 1.3

The Twitter Signin sub-module, as you may have guessed, allows Drupal users to register and login using their Twitter account.

Fig 1.4

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.

So to setup the module you need to create a Twitter application on dev.twitter.com and configure the module with [OAuth](Twitter to use the application.

If you want to learn how to setup an application and the Twitter module, then check out these two free videos: How to Create a Twitter Application and How to Configure the Twitter and OAuth Module.

Twitter Block

Twitter Block allows you to add embedded timelines into any Drupal site using the Block system.

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.

Fig 1.1

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)

If you need to add Twitter cards to your Drupal site then take look at the “Metatag: Twitter Cards” sub-module that ships with Metatag.

Twitter cards make it possible to attach rich media to tweets like images, videos and article summaries.

Fig 1.1

Adding Twitter cards support to a website is pretty easy because it’s all done via meta tags and for Drupal we have the Metatag module.

To learn how to setup Twitter cards in Drupal, check out my tutorial called Display Twitter Cards in Drupal Using Meta Tags Module.

Twitter Pull

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:

Conclusion

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.

About the Author

Ivan is the founder of Web Wash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 10 years and has successfully completed several large Drupal projects in Australia.

Leave a Reply 13 comments

Bill Rosser - November 20, 2013 Reply

Great summary of Drupal/Twitter integration!

dddave - November 21, 2013 Reply

If you want to embed tweets INTO the content area (via an input filter) you can do it, too. This patch for the Twitter module https://drupal.org/node/1365452 works handsomely and could use some +1s to finally get included.
Such a common feature today yet hardly anybody seems to request it.

    Ivan Zugec - November 21, 2013 Reply

    Thanks for the link.

guy - October 13, 2014 Reply

is there any way to get new comments on drupal nodes (like this one of mine) posted to twitter?

    Ivan Zugec - October 14, 2014 Reply

    I don’t think you can do it out of the box. You’ll have to write some custom code or look at using Rules.

      demos o. - June 3, 2016 Reply

      I’m late to the party here, but in researching a similar user request tody I ran across your article and and have also followed this drupal.org topic:
      https://www.drupal.org/node/2404599
      It’s a year since the last post on it, but maybe some of what’s already there will help someone (if not guy himself… I know — pro’ly too late to help.)

        Ivan Zugec - June 5, 2016 Reply

        Thanks for the link.

Umair - April 29, 2017 Reply

How to setup twitter on acquia dev desktop?

Umair - April 29, 2017 Reply

Thank you for your quick reply. I have read this page before, but there is a confusion. What should I fill in website and callback url? See this for more details https://drupal.stackexchange.com/questions/235179/how-to-setup-twitter-on-acquia-dev-desktop

    Ivan Zugec - April 30, 2017 Reply

    Hi Umair,

    I don’t know the answer off the top of my head. I’ll have to research it.

    It’s been years since I last used the Twitter module. Try asking in the Twitter module issue queue.

    Cheers,
    Ivan

      Umair - May 5, 2017 Reply

      See the updated Q on stackexchange and you will get the answer. And thank for writing detailed and easy to understand articles.

Leave a Reply: