The document discusses Twitter's streaming APIs. It describes the different types of streams including the firehose, filter, sample, user and site streams. It provides examples of how to access user streams and site streams and the type of data that can be obtained from each including tweets, direct messages, events and more. Key aspects like using OAuth, JSON, and asynchronous processing are also highlighted.
15. What is Streaming?
‣ Push delivery of tweets, as opposed to the REST (pull) API
‣ Implemented as HTTP long poll, aka the web page that never
ends
‣ JSON (preferred) or XML content
TM
Wednesday, September 8, 2010
16. Streaming “Products”
‣ hoses - slices of the entire tweet corpus
‣ firehose
‣ filter
‣ sample
‣ users - focused on specific users’ content
‣ user streams
‣ site streams
TM
Wednesday, September 8, 2010
17. Getting Started
‣ cURL is your friend
‣ twurl is an even better friend
‣ Many libraries available
TM
Wednesday, September 8, 2010
18. User Streams
‣ Goals
‣ Support single-user connections (e.g. desktop applications)
‣ Reduce dependency on polling
‣ Provide a true real time experience to users
TM
Wednesday, September 8, 2010
19. Data Delivered
‣ All data is delivered as a JSON message on a single line
‣ First message - your friends
‣ Statuses
‣ Direct Messages
‣ Events
TM
Wednesday, September 8, 2010
20. What are Events?
‣ Events represent user activities that are not message delivery
‣ This includes
‣ favorites
‣ follows
‣ profile updates
TM
Wednesday, September 8, 2010
21. Event Schema
‣ event - indicates the type of event
‣ source - the user who initiated the action
‣ target - the user who owns the affected object.
‣ target_object (optional) - the affected object
‣ created_at - the time this happened
TM
Wednesday, September 8, 2010
22. Site Streams
‣ Goals
‣ Like User Streams
‣ But for “services”, not desktop apps.
‣ Multiplex many users’ events onto a single connection
TM
Wednesday, September 8, 2010
23. Data Delivered
‣ Just the same as user stream
‣ But every message is wrapped with a “for_user” tag, which gives
the ID of the user to whom this message applies
TM
Wednesday, September 8, 2010
24. Keys to Success
‣ Use OAuth
‣ Use JSON
‣ Process messages asynchronously
‣ Make sure you have adequate bandwidth
‣ Be prepared for additional message types
TM
Wednesday, September 8, 2010
25. More Info! Follow us at
twitter.com/jkalucki
twitter.com/mccv
http://dev.twitter.com/pages/streaming_api
TM
Wednesday, September 8, 2010
29. Basic Example
<script src="http://platform.twitter.com/widgets.js"
type="text/javascript"></script>
<a href="http://twitter.com/share"
class="twitter-share-button">Tweet</a>
TM
Wednesday, September 8, 2010
30. Customising
‣ url - URL of the page to share
‣ via - Screen name of the user to attribute the Tweet to
‣ text - Default Tweet text
‣ related - Related accounts
‣ count - Count box position
‣ lang - The language for the Tweet Button
‣ counturl - The URL to which your shared URL resolves to
TM
Wednesday, September 8, 2010
31. Customised Example
<script src="http://platform.twitter.com/widgets.js"
type="text/javascript"></script>
<div>
<a href="http://twitter.com/share"
class="twitter-share-button"
data-url="http://dev.twitter.com/pages/tweet_button"
data-via="twitterapi"
data-text="Checking out this page about Tweet Buttons"
data-related="anywhere:The Javascript API"
data-count="vertical">Tweet</a>
</div>
TM
Wednesday, September 8, 2010
32. Customised Example with Short URL
<script src="http://platform.twitter.com/widgets.js"
type="text/javascript"></script>
<div>
<a href="http://twitter.com/share"
class="twitter-share-button"
data-url="http://bit.ly/twitter-api-announce"
data-counturl="http://groups.google.com/group/twitter-api-announce"
data-count="vertical">Tweet</a>
</div>
TM
Wednesday, September 8, 2010
33. More Info!
http://dev.twitter.com/pages/tweet_button
TM
Wednesday, September 8, 2010
34. Stay Informed... Join
bit.ly/twitter-anywhere-talk
bit.ly/twitter-dev-talk
Important Stuff
@twitterapi
status.twitter.com
bit.ly/twitter-api-announce
TM
Wednesday, September 8, 2010
35. Help... Check out
dev.twitter.com
TM
Wednesday, September 8, 2010
36. Join the Flock! Find out more
jobs.twitter.com
TM
Wednesday, September 8, 2010
37. Questions? Follow us at
twitter.com/twitterapi
twitter.com/themattharris
twitter.com/mccv
TM
Wednesday, September 8, 2010