screenshot of block display
Easily display tweets filtered by Twitter handle, timeline, or search term in a Drupal block. You can control how many tweets should display and whether to include replies or retweets.

A single set of Twitter app credentials is used site-wide, but each block instance can display different tweets with different display settings.

This module uses the application only (read-only access to public information) via the Twitter API.

By design, theming is minimal. Developers are expected to customize the display via their chosen theme.

screenshot of block configuration

Configuration

  1. You first need a Twitter App. Sign in to Twitter and go to https://apps.twitter.com/ . Copy the "key" and "secret" associated with your new app.
  2. After installing the module in Drupal, go to Configuration > Media > Twitter Widgets (admin/config/media/twitter_profile_widget). Enter the Twitter App key and secret you created in step 1.
  3. Go to Admin > Structure > Block Layout > Custom Block Library > Add custom block (/block/add) and create one or more widgets.

Staying secure

Your Twitter app consumer key and consumer secret will be stored in a Drupal configuration entity. If using version control and configuration management, use a tool such as config_ignore and config_exclude to prevent exposing your Twitter app credentials, or a Drupal core solution such as $settings['config_exclude_modules'].

For non-UI management & deployment across environments, consider referencing these credentials through the filesystem, either through reference via settings.php or the equivalent:

$path = 'sites/default/files/private/twitter.json';
if (file_exists($path)) {
  $json_text = file_get_contents('sites/default/files/private/twitter.json');
  $twitter_widget = json_decode($json_text, TRUE);
  $config['twitter_profile_widget.settings']['twitter_widget_key'] = $twitter_widget['twitter_widget_key'];
  $config['twitter_profile_widget.settings']['twitter_widget_secret'] = $twitter_widget['twitter_widget_secret'];
}
Supporting organizations: 
Initial development
Professional development time

Project information

Releases