サイトのトップへ戻る

Twitter 開発者 ドキュメント日本語訳

リアルタイムにツイートを抽出する技術

Many real-time display integrations want to highlight specific curated Tweets. Perhaps you want to display the Tweets you’ve determined are the best on a display at a conference, or mark a collection of Tweets to be rendered along the bottom of the screen during a television show, or to build a curated image gallery of some kind. These high-level instructions will help guide you to the implementation that’s best for your scenario.

Begin with a single account. Let’s call this account “@engaged,” as it represents the user who is engaging with content and marking which Tweets should be curated.

  1. The @engaged user connects to User Streams.
    • They’ll be streamed events “around” @engaged. One of the types of events that will be streamed are events when @engaged favorites a Tweet.
    • This connection remains long-standing — for as long as the event is running.
  2. The @engaged user logs in to Twitter, or a Twitter client. They “read” Tweets. When they see a Tweet that should become part of the curated set, they perform the “favorite” action on that Tweet.
  3. When that favorite action occurs, the @engaged user on the User Streams API will get a streamed event describing that @engaged favorited Tweet XYZ. This event’s “event” attribute indicates what happened, in this case a “favorite.” The “target_object” will hold the full Tweet JSON that was favorited. More sophisticated integrations may want to leverage other signals, like unfavoriting as a signal for removing a Tweet from the curated set.
  4. The software should set aside the Tweet ID and Tweet object received in the collection that represents your curated bucket. This bucket or queue represents the data you’ll work with in displaying curated content.
  5. Finally, a last piece of your software stack will read from that bucket of curated content and choose how to render it appropriately for your scenario. Keep in mind that there are Developer Display Requirements and broadcast guidelines to follow.

    The Tweet objects you’ve collected will also often contain Tweet entities that describe uploaded media like photos on pic.twitter.com, or videos from twitvid.com and so on. These entities are important to consider when rendering your curated content. This external article has some tips on rendering rich content specifically. For pic.twitter.com images, everything you need to render the Tweet is already included in your curated Tweet object.

Variations on this theme

There are a few related but slightly different implementations you may be interested in. Instead of displaying or broadcasting the Tweets you’ve curated through the favoriting model, perhaps you would rather do something else with them.

  • Retweeting curated Tweets from another account — Perhaps the Twitter account representing your reality show wants to reTweet the best Tweets about that night’s episode. In this case, instead of displaying the Tweets in your “curation queue,” you would leverage the access token belonging to your show’s account and reTweet the Tweet IDs of each curated Tweet.
  • Following or building a list of authors of curated Tweets — Perhaps you want to keep tabs on the users who authored those fantastic Tweets you’ve curated. You could follow the authors or add them to a list. Once they’re in a list, you could display their Tweets using the list widget.
  • Displaying favorites on your site — The Tweets that @engaged favorited are also available in a few different other formats including their favorites timeline. You can display those favorited Tweets on your site using the favorites widget or with a more robust API integration.

Additionally, @couch has authored an open source tool called Ospriet. Ospriet follows similar patterns as documented here, allowing for live audience participation at events. You can read more about Ospriet here.