twitter user streams api

28
Let’s Hack the Twitter User Streams API @aral #warblecamp

Upload: aral-balkan

Post on 18-May-2015

1.207 views

Category:

Technology


3 download

DESCRIPTION

My quickly-hacked together presentation for Warblecamp on the new Twitter User Streams API.

TRANSCRIPT

Page 1: Twitter User Streams Api

Let’s Hack the Twitter User Streams API

@aral #warblecamp

Page 4: Twitter User Streams Api

BETA

Page 7: Twitter User Streams Api

Client-side use only

Page 8: Twitter User Streams Api

(Continue to use stream.twitter.com for

service to serviceintegrations.)

John Kalucki (Twitter Dev Mailing List, May 3)

Page 9: Twitter User Streams Api

JSON only

Page 10: Twitter User Streams Api

1) If the key "text" exists, this is a status2) If the key "delete" exists, this is a status deletion3) If the key "scrub_geo" exists, this is a geo-tagging deletion message4) If the key "direct_message" exists, this is a direct message5) If the key "event" exists, this is a social event

Mark McBride (Twitter Dev Mailing List, May 3)

Page 11: Twitter User Streams Api

oAuth support live (as of May 7th,

2010)

Page 12: Twitter User Streams Api

Fully hydrated objects (as of May

3rd)

Page 13: Twitter User Streams Api

1) The user's latest status may not be included2) The user's status count may not be included3) The user's favorites count may not be included

Mark McBride (Twitter Dev Mailing List, May 3)

Page 14: Twitter User Streams Api

{"created_at"=>"Mon May 03 17:42:55 +0000 2010", "target_object"=> {"coordinates"=>nil,  "truncated"=>false,  "created_at"=>"Sun Jun 28 23:10:35 +0000 2009",  "favorited"=>false,  "contributors"=>nil,  "text"=>"looking at cricket eyes!",  "id"=>4,  "geo"=>nil,  "in_reply_to_user_id"=>nil,  "source"=>"web",  "place"=>nil,  "user"=>   {"profile_background_tile"=>false,    "name"=>"Ray",    "profile_sidebar_border_color"=>"87bc44",    "profile_sidebar_fill_color"=>"e0ff92",    "location"=>nil,    "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",    "profile_image_url"=>"/images/default_profile_4_normal.png",    "profile_link_color"=>"0000ff",    "contributors_enabled"=>false,    "url"=>nil,    "favourites_count"=>1,    "id"=>4,    "utc_offset"=>-21600,    "profile_text_color"=>"000000",    "protected"=>true,    "lang"=>"en",    "followers_count"=>3,    "notifications"=>nil,    "verified"=>false,    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 15: Twitter User Streams Api

    "profile_sidebar_fill_color"=>"e0ff92",    "location"=>nil,    "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",    "profile_image_url"=>"/images/default_profile_4_normal.png",    "profile_link_color"=>"0000ff",    "contributors_enabled"=>false,    "url"=>nil,    "favourites_count"=>1,    "id"=>4,    "utc_offset"=>-21600,    "profile_text_color"=>"000000",    "protected"=>true,    "lang"=>"en",    "followers_count"=>3,    "notifications"=>nil,    "verified"=>false,    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 16: Twitter User Streams Api

    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 17: Twitter User Streams Api

   "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 18: Twitter User Streams Api

   "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 19: Twitter User Streams Api

   "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 20: Twitter User Streams Api

  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

Page 21: Twitter User Streams Api

{

 "target_object"=>  "user"=>   {    "name"=>"Ray",   },

 "event"=>"favorite", "target"=> {  "name"=>"Ray",},

 "source"=> {  "name"=>"Jack",}

Page 22: Twitter User Streams Api

Direct Messages

Page 23: Twitter User Streams Api

{"direct_message"=>

 {"created_at"=>"Wed Apr 28

14:56:31 +0000 2010", //...

  "sender_screen_na

me"=>"user1",  "sender"=>

Page 24: Twitter User Streams Api

Resources

Page 25: Twitter User Streams Api

Earlybird sample app:

http://github.com/zbowling/earlybird/

Page 26: Twitter User Streams Api

earlybird.rb -c consumer_token -s consumer_secret -a access_token -S access_secret [-d] [-f] [-t key,words] [-u url] [-h host]options:   -c   --consumer_token   consumer token  -s   --consumer_secret  consumer secret  -a   --access_token     access token  -S   --access_secret    access secret  -r                      show in reply too (takes a lot of API requests)  -d                      debug mode, read json from stdin  -f                      filter out @replies from users you don't follow  -g                      growl notifications for new tweets  -t                      track keywords separated by commas.  -u                      userstream path. Default: /2b/user.json  -h                      userstream hostname: Default: betastream.twitter.com

Page 27: Twitter User Streams Api

Useful clients:Tweetstream

(Ruby)intridea/tweetstrea

m

Page 28: Twitter User Streams Api

(See @tommorris’s session for more

info)