Mitesh Patel in IT - Information Technology, drupal, Twitter Digital Marketing Manager • Addweb Solution May 20, 2020 · 2 min read · +700

Twitter and Drupal

Twitter and Drupal

Twitter and Drupal

In this chapter, we're going to integrate Twitter with Drupal. If you have a Twitter account, you can post your tweets to your Drupal site automatically at the same time you post them to your Twitter home page. You can also post node content from your Drupal service site to your Twitter home page as tweets. We'll look at configuring this integration in detail and also look at setting up automatic actions and triggers to occur when you save a new node content on your Drupal Development site.

In this chapter, we will install and enable a few Twitter-based modules to allow for integration with the Twitter web service API, including the Twitter module, Daily Twitter, and Tweet modules.

To summarize, in this chapter we will:

· Enable the Twitter module and configure it

· Post tweets from our Twitter account to blocks on our Drupal website

· Post links to nodes and node content from our Drupal site to our Twitter home page

· Enable and configure the Tweet module

Twitter and Drupal

Twitter is a popular and widely used micro-blogging application and website. You can sign up for a Twitter account and post tiny snippet-based blog entries, 140 characters, or less, to your Twitter home page. You can log in to your Twitter account and post your 140 character entry into the What's happening? text area box and then click on the Tweet button to publish it. The tweet will appear on your account's home page—your default Twitter home page—and it will be shared on the main Twitter home pages of your followers.

To send a tweet to another user, you can use the hashtag in front of their username in your post. So, for example, if I was going to send myself a tweet, I would add this in my text area box before adding my post: #jamesweblabs. For more on the history and functionality of Twitter, check out the Wikipedia entry at http:// Twitter also has a detailed Help and support documentation section on its main site at

You may want to integrate Twitter with your Drupal site, to do things such as posting all of your most recent tweets into a Drupal block that will appear on your home page. You also may want to run this block automatically via a web service integration so that the block updates automatically whenever you post a new tweet to your Twitter account. Drupal and Twitter can easily integrate through these web services by using contributed modules.

In this chapter, we're going to install, configure, and use the Twitter module so that we can integrate our Twitter account with our Drupal user account; we can also post tweets to the sidebar block on our site. With the Twitter module, we'll also expose some of its fields to the Views module and be able to create more powerful and dynamic listings of Twitter-based content.

We'll also look at other contributed modules including Tweet.

The Twitter API

The Twitter API and service integration with Drupal use the REST (Representational State Transfer) API protocol and a Streaming API protocol. Twitter does state in its API documentation that the service does not offer unlimited usage. Twitter does impose limits on the number of requests and updates made to its service API. The REST service is HTTP-based and uses GET and POST requests. GET is used to retrieve data so, in our case, this will be used when our Drupal site tries to receive the latest Tweet posted to your Twitter account. POST requests are used when you submit, update, or delete node data that you have sent over to Twitter and posted as a Tweet using the Twitter module.

Using REST as the protocol, the API does support various formats for data transfer including XML, JSON, RSS, and Atom. For more details on the Twitter API and how to use it, see the Twitter API documentation for developers at:

The Twitter module

The Twitter module is available via its Drupal project page at The module allows for integration with Twitter's API web service. It allows you to integrate your Twitter account with your Drupal user account; post Tweets to a block in Drupal; and allows your Drupal users to post to their Twitter account using Drupal node content. Drupal Views also integrates with the module and you can create your own customized Views-based listings of Twitter content.

The module gives you a default block called User Tweets and also a user profile

page titled user's tweets. We'll set both of these up in the examples that follow.