Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Twitter API (v2) Block

Security covered Under active development 288 sites

This module provides blocks to display tweets from the Twitter API. It uses Twitter API v2 and allows you to configure blocks to show tweets based on keywords, hashtags, users, and more.

The Twitter API is no longer free to use. This module will continue to exist but it won't display anything unless you subscribe to at least the Basic plan (currently $100.00/month 😱)

This module provides blocks to display/embed tweets in Drupal.

It uses the Twitter API v2 with a custom service performing request from Drupal. When displaying embed tweets, the JavaScript library is automagically loaded from Twitter.

So to say, this module have no external dependencies except to the key module which is required to securely save your Twitter application's credentials.

If the Token module exists and is enabled, you can use tokens in your search query.

Configuration

Create a project with an application on Twitter and copy/paste credentials into a new key in Drupal (e.g. Admin > Config > System > Keys):

Usage

Create a Twitter block as follow:

  • Go to Admin > Block layout
  • Place a new Twitter search block somewhere
  • Configure the search (e.g. see examples below)
  • Save the block and enjoy your tweets!

Tweets and embed tweets are rendered with two editable templates:

  • tweets.html.twig
  • tweet.html.twig

Examples

This module uses the powerful query parameter provided by Twitter API v2 giving us an infinite number of possibilities... but here are a few common use cases:

Display tweets matching word(s)

apple
apple chocolate
apple OR iphone ipad
manzana lang:es has:media -is:retweet

Display tweets for a specific #hashtag

#drupal
#drupal has:media
#drupal has:links -is:retweet

Display tweets in the current language

#drupal lang:fr
#drupal lang:[language:langcode]

Display tweets from a given user

from:drupal
from:[your-token-with-the-twitter-user-name]

Requirements

Twitter API Block Entity Reference depends on:

  • Block (core)
  • Key (contrib)

Complementary modules

Slack channel

Join me in Slack in the #twitter-api-block channel! Details on how to connect to Drupal Slack here

Drupal 8–10 · not 11

Ask your assistant about Twitter API (v2) Block

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • Key
  • block Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Feb 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
4.0.5 Stable 8–10 Mar 9, 2023
4.0.4 Stable 8–10 Feb 17, 2023