The Wayback Machine - https://web.archive.org/web/20151028165929/https://dev.twitter.com/web/intents

Web Intents

By using Web Intents, you agree to the Developer Rules of the Road.

Make it easy to bring interactivity to Tweets that you display on the web.

Web Intents provide popup-optimized flows for working with Tweets & Twitter Users: Tweet, Reply, Retweet, Favorite, and Follow. They make it possible for users to interact with Twitter content in the context of your site, without leaving the page or having to authorize a new app just for the interaction. Web intents are mobile friendly, and super easy to implement.

Working with Web Intents

Web Intents are the simplest way to make the Tweets you display on your website interactive.

Web Intents automatically detect whether the end user is currently logged in to twitter.com and asks for login when necessary. If the user does not yet have a Twitter account, they’ll have the opportunity to create one before realizing their original intention. No need to register an application or API key.

Web Intents don’t require Javascript, but it makes it easier to pop them up most elegantly. We recommend rendering each Web Intent at 550px by 420px. If you use the provided pop-up Javascript, the heights will be adjusted for you. The pop-up will automatically close after the user has seen their intent to completion and users will be asked to confirm their action before it is executed.

Web Intents are also mobile browsing friendly and ready for use on iOS, Android, and most modern mobile devices. Web Intents are just URLs that are meant to be loaded in a browser window, whether the current window or one popped up via HTML or Javascript. While you can provide links to intents within IFRAMEs and widgets, the resultant pages cannot be loaded in an IFRAME.

Images for Twitter Twitter bird logo blue 16x16 birds, Tweet favorite stars for favoriting, Tweet reply icon icons for replying & Retweet icon retweeting are all available on our Image Resource. Consult our Display Requirements for tips on rendering Tweets and other Twitter resources.

If your audience speaks a language other than English, we recommend you use localized intents. Consult our International glossary page to get the most accurate translations.

Get Started

Web Intents can be invoked flexibly through a light combination of JavaScript and HTML and are meant to be opened in a new window.

The easiest way to use intents is to include this SCRIPT tag on any web page you wish to invoke an intent. If you’ve already setup the Tweet Button, you’re already prepared for Web Intents.

When combined with standard anchor tags and familiar iconography like the examples below, this JavaScript will automatically open a window of the appropriate size when clicked. You only need to load platform.twitter.com/widgets.js once.

<script type="text/javascript" async src="//platform.twitter.com/widgets.js"></script>
<a href="https://twitter.com/intent/tweet?in_reply_to=463440424141459456">Reply</a>
<a href="https://twitter.com/intent/retweet?tweet_id=463440424141459456">Retweet</a>
<a href="https://twitter.com/intent/favorite?tweet_id=463440424141459456">Favorite</a>

Meet the Web Intents

Tweet Intents

User Intents

Tweet or Reply to a Tweet

https://twitter.com/intent/tweet

View the Tweet Web Intent documentation for more information about the Tweet intent.

Retweet a Tweet

https://twitter.com/intent/retweet

Retweets are a powerful way to enable your users to share your content with their followers.

The official icon for retweeting is . Other image resources »

Web Intent retweet

Supported Parameters

  • tweet_id

    Every Tweet is identified by an ID. You can find this value from the API or by viewing the permalink page for any Tweet, usually accessible by clicking on the “published at” date of a tweet.

    Usage Examples

    36287294927413248

  • related

    Suggest additional Twitter usernames related to the Tweet as comma-separated values. Twitter may suggest these accounts to follow after the posted retweet.

    You may provide a brief description of how the account relates to the Tweet with a URL-encoded comma and text after the username.

    Usage Examples

    twitterapi,twittermedia,twitter

    twitterapi%3AFor%20platform%20info,twittermedia%3AFor%20great%20tips

Favorite a Tweet

https://twitter.com/intent/favorite

Users favorite for a variety of reasons: when they love a Tweet, when they want to save it for later, or to offer a signal of thanks. The favorite intent allows you to provide this Tweet Action and follow up with relevant suggested accounts for the user to follow.

The official icon for favoriting is Tweet favorite. Other image resources »

Web Intent favorite

Supported Parameters

  • tweet_id

    Every Tweet is identified by an ID. You can find this value from the API or by viewing the permalink page for any Tweet, usually accessible by clicking on the “published at” date of a tweet.

    Usage Examples

    35782000644194304

  • related

    Suggest additional Twitter usernames related to the Tweet as comma-separated values. Twitter may suggest these accounts to follow after the user posts his or her Tweet.

    You may provide a brief description of how the account relates to the Tweet with a URL-encoded comma and text after the username.

    Usage Examples

    twitterapi,twittermedia,twitter

    twitterapi%3AFor%20platform%20info,twittermedia%3AFor%20great%20tips

Mini-Profile

https://twitter.com/intent/user

This Intent provides an unobtrusive way to link names of people, companies, and services to their Twitter accounts. The resultant popup prominently features the account’s profile picture, bio, summary statistics, noteworthy followers, recent tweets and an easy-to-use Follow button.

A Twitter bird is an easy way to denote this intent. . More birds & other image resources »

Twitter user Web Intent

Supported Parameters

  • screen_name

    Every Twitter user has a screen name, but they are subject to change. We recommend using user_id whenever possible.

    Usage Examples

    biz

  • user_id

    Twitter User IDs are available from the API and uniquely identify a user.

    Usage Examples

    3308337

Follow

https://twitter.com/intent/follow

A follow Web Intent displays an inline sign in form for logged out users and follows the target Twitter account on successful login.

Localization

If you want to ensure that the Web Intent you’re rendering is displayed in a specific language, you can pass a lang parameter to any Intent URL.

Supported Languages

Optimization

Re-evaluating content

If you’ve dynamically changed content on your page and want to re-evaluate anchor tags matching a.twitter-share-button or a.twitter-follow-button, you can execute the following on snippet of Javascript:

 twttr.widgets.load();

Limited Dependencies

Some sites may prefer to embed the unobtrusive Web Intents pop-up Javascript inline or without a dependency to platform.twitter.com. The snippet below will offer the equivalent functionality without the external dependency.

(function() {
  if (window.__twitterIntentHandler) return;
  var intentRegex = /twitter\.com(\:\d{2,4})?\/intent\/(\w+)/,
      windowOptions = 'scrollbars=yes,resizable=yes,toolbar=no,location=yes',
      width = 550,
      height = 420,
      winHeight = screen.height,
      winWidth = screen.width;

  function handleIntent(e) {
    e = e || window.event;
    var target = e.target || e.srcElement,
        m, left, top;

    while (target && target.nodeName.toLowerCase() !== 'a') {
      target = target.parentNode;
    }

    if (target && target.nodeName.toLowerCase() === 'a' && target.href) {
      m = target.href.match(intentRegex);
      if (m) {
        left = Math.round((winWidth / 2) - (width / 2));
        top = 0;

        if (winHeight > height) {
          top = Math.round((winHeight / 2) - (height / 2));
        }

        window.open(target.href, 'intent', windowOptions + ',width=' + width +
                                           ',height=' + height + ',left=' + left + ',top=' + top);
        e.returnValue = false;
        e.preventDefault && e.preventDefault();
      }
    }
  }

  if (document.addEventListener) {
    document.addEventListener('click', handleIntent, false);
  } else if (document.attachEvent) {
    document.attachEvent('onclick', handleIntent);
  }
  window.__twitterIntentHandler = true;
}());

How to Render a Tweet

Consult our Display Guidelines for more information »

Useful Resources