intro to developing for @twitterapi

99
TM Developing with @twitterapi Developing for Twitter @ Leeds Metropolitan University May 12, 2010 #twitterapi #twcoding

Upload: raffi-krikorian

Post on 26-Jan-2015

109 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Intro to developing for @twitterapi

TM

Developing with @twitterapi

Developing for Twitter @ Leeds Metropolitan UniversityMay 12, 2010

#twitterapi #twcoding

Page 2: Intro to developing for @twitterapi

giving an @ignite talk at @chirp entitled

"energy / tweet".about 2 minutes ago via mobile web from Fort Mason, San Francisco

giving a talk about coding against the @twitterapi at Leeds

Leeds, UK

Page 3: Intro to developing for @twitterapi

Calls toWhat does our traffic look like?

76%

24%

Page 4: Intro to developing for @twitterapi

An application for everybody

100,000 applications

Page 5: Intro to developing for @twitterapi

ClientsTweet like you mean it

Page 6: Intro to developing for @twitterapi
Page 7: Intro to developing for @twitterapi
Page 8: Intro to developing for @twitterapi
Page 9: Intro to developing for @twitterapi
Page 10: Intro to developing for @twitterapi
Page 11: Intro to developing for @twitterapi
Page 12: Intro to developing for @twitterapi
Page 13: Intro to developing for @twitterapi
Page 14: Intro to developing for @twitterapi

Focusing on reading stuff

Consumption

Page 15: Intro to developing for @twitterapi
Page 16: Intro to developing for @twitterapi
Page 17: Intro to developing for @twitterapi
Page 18: Intro to developing for @twitterapi

And the just wacky...

Creative

Page 19: Intro to developing for @twitterapi
Page 20: Intro to developing for @twitterapi
Page 21: Intro to developing for @twitterapi
Page 22: Intro to developing for @twitterapi
Page 23: Intro to developing for @twitterapi

What is ? How to use the Twitter Platform

Page 24: Intro to developing for @twitterapi

What is ? ‣ REST API

‣ provides the “basic” functionality - tweet, follow, etc.

‣ all functions available on your timeline on twitter.com

‣ Search API

‣ real-time search index

‣ get “top tweets” / relevant search results

‣ Streaming API

‣ HTTP long-poll connection

‣ tweets come out of the system in real-time

Page 25: Intro to developing for @twitterapi

The goals of ‣ To be ridiculously simple

‣ To be obvious

‣ To be self-describing

Page 26: Intro to developing for @twitterapi

Tools of the trade‣ dev.twitter.com

‣ documentation center

‣ API console for quick testing and exploration

‣ curl and a web browser

‣ testing unauthenticated endpoints

‣ CLI to get a raw dump of the interaction

‣ twurl

‣ OAuth-enabled version of curl

Page 27: Intro to developing for @twitterapi

Authenticating to ‣ OAuth 1.0a

‣ signing “write” requests

‣ give visibility into the stack

‣ Applications don’t have a user’s username / password

‣ user can change password at any time

‣ user is secure in knowing his/her password not being stored outside of

‣ user can revoke permissions to app at any time

Page 28: Intro to developing for @twitterapi

Libraries‣ PHP - http://github.com/abraham/twitteroauth

‣ Java - http://github.com/fernandezpablo85/scribe

‣ Ruby - http://oauth.rubyforge.org/

‣ C / C++ - http://liboauth.sourceforge.net/

‣ Actionscript / Flash - http://code.google.com/p/oauth-as3/

Page 29: Intro to developing for @twitterapi

twurl‣ http://github.com/marcel/twurl

‣ Command line tool to interact with using OAuth

‣ Transparently handles OAuth signing against

‣ authorize against to get access tokens

‣ from there on out, all requests are signed

Page 30: Intro to developing for @twitterapi

Limits‣ 350 API calls/hour using OAuth against api.twitter.com

‣ unauthenticated it goes against the source IP address

‣ authenticated it goes against the calling user‣ “Natural” limits on

‣ number of tweets sent‣ number of DMs sent‣ number of followings / unfollowings

‣ Status limits‣ can’t have duplicate tweets

‣ can’t have malware links in tweets

Page 31: Intro to developing for @twitterapi

dev.twitter.comThe developer console

Page 32: Intro to developing for @twitterapi

Creating an appYour own small playground

Page 33: Intro to developing for @twitterapi
Page 34: Intro to developing for @twitterapi
Page 35: Intro to developing for @twitterapi
Page 36: Intro to developing for @twitterapi

Using the consoleInteracting with @ for fun and profit

Page 37: Intro to developing for @twitterapi
Page 38: Intro to developing for @twitterapi
Page 39: Intro to developing for @twitterapi
Page 40: Intro to developing for @twitterapi
Page 41: Intro to developing for @twitterapi
Page 42: Intro to developing for @twitterapi

Browsing docsRemembering how to read

Page 43: Intro to developing for @twitterapi
Page 44: Intro to developing for @twitterapi
Page 45: Intro to developing for @twitterapi
Page 46: Intro to developing for @twitterapi

Anatomy of theREST APIWhat if I want to write code?

Page 47: Intro to developing for @twitterapi

GETing from the APIReading, reading, reading

Page 48: Intro to developing for @twitterapi

GETing from the API‣ For most cases, completely wide open

‣ Can do a HTTP connect and a simple GET request

‣ “Protected” information may require authentication (covered later)

‣ getting the tweet of a protected user

‣ getting the timeline of a user

Page 49: Intro to developing for @twitterapi

Status objectsThe basis of everything

Page 50: Intro to developing for @twitterapi

Getting a status object‣ Figure out the ID of the status objects

‣ Construct the URL for statuses/show

‣ Grab it!

Page 51: Intro to developing for @twitterapi
Page 53: Intro to developing for @twitterapi

Taking a look at status 13762161921[raffi@tw-mbp13-raffi Desktop]$ curl http://api.twitter.com/1/statuses/show/13762161921.xml<?xml version="1.0" encoding="UTF-8"?><status> <created_at>Tue May 11 01:58:56 +0000 2010</created_at> <id>13762161921</id> <text>...and another late night</text> <source>&lt;a href=&quot;http://mehack.com&quot; rel=&quot;nofollow&quot;&gt;@raffi's Test App&lt;/a&gt;</source> <truncated>false</truncated> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name></in_reply_to_screen_name> <user> <id>8285392</id> <name>raffi</name> <screen_name>raffi</screen_name> <location>San Francisco, California</location> <description>Tinkering, writing, engineering, and breaking things on the @twitterapi.</description> <profile_image_url>http://a1.twimg.com/profile_images/364041028/raffi-headshot-casual_normal.png</profile_image_url> <url>http://www.mehack.com/</url> <protected>false</protected> <followers_count>2862</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>424</friends_count> <created_at>Sun Aug 19 14:24:06 +0000 2007</created_at> <favourites_count>45</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273278095/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>true</following> <statuses_count>2373</statuses_count> <lang>en</lang> <contributors_enabled>false</contributors_enabled> </user> <geo/> <coordinates/> <place/> <contributors/></status>

Page 54: Intro to developing for @twitterapi

Dissecting a status object

{"id"=>12296272736,

"text"=>

"An early look at Annotations:

http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453",

"created_at"=>"Fri Apr 16 17:55:46 +0000 2010",

"in_reply_to_user_id"=>nil,

"in_reply_to_screen_name"=>nil,

"in_reply_to_status_id"=>nil

"favorited"=>false,

"truncated"=>false,

"user"=>

{"id"=>6253282,

"screen_name"=>"twitterapi",

"name"=>"Twitter API",

"description"=>

"The Real Twitter API. I tweet about API changes, service issues and

happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",

"url"=>"http://apiwiki.twitter.com",

"location"=>"San Francisco, CA",

"profile_background_color"=>"c1dfee",

"profile_background_image_url"=>

"http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",

"profile_background_tile"=>false,

"profile_image_url"=>"http://a3.twimg.com/profile_images/689684365/api_normal.png",

"profile_link_color"=>"0000ff",

"profile_sidebar_border_color"=>"87bc44",

"profile_sidebar_fill_color"=>"e0ff92",

"profile_text_color"=>"000000",

"created_at"=>"Wed May 23 06:01:13 +0000 2007",

"contributors_enabled"=>true,

"favourites_count"=>1,

"statuses_count"=>1628,

"friends_count"=>13,

"time_zone"=>"Pacific Time (US & Canada)",

"utc_offset"=>-28800,

"lang"=>"en",

"protected"=>false,

"followers_count"=>100581,

"geo_enabled"=>true,

"notifications"=>false,

"following"=>true,

"verified"=>true},

"contributors"=>[3191321],

"geo"=>nil,

"coordinates"=>nil,

"place"=>

{"id"=>"2b6ff8c22edd9576",

"url"=>"http://api.twitter.com/1/geo/id/2b6ff8c22edd9576.json",

"name"=>"SoMa",

"full_name"=>"SoMa, San Francisco",

"place_type"=>"neighborhood",

"country_code"=>"US",

"country"=>"The United States of America",

"bounding_box"=>

{"coordinates"=>

[[[-122.42284884, 37.76893497],

[-122.3964, 37.76893497],

[-122.3964, 37.78752897],

[-122.42284884, 37.78752897]]],

"type"=>"Polygon"}},

"source"=>"web"}

The tweet's unique ID. These

IDs are roughly sorted &

developers should treat them

as opaque (http://bit.ly/dCkppc).

Text of the tweet.

Consecutive duplicate tweets

are rejected. 140 character

max (http://bit.ly/4ud3he).

Tweet's

creation

date.

DE

PR

EC

AT

ED

The ID of an existing tweet that

this tweet is in reply to. Won't

be set unless the author of the

referenced tweet is mentioned.The screen name &

user ID of replied to

tweet author. Truncated to 140

characters. Only

possible from SMS.

The a

uth

or

of th

e tw

eet. T

his

em

bedded o

bje

ct can g

et out of sync.

The a

uth

or's

user

ID.

The author's

user name.

The author's

screen name.

The author's

biography.

The author's

URL.The author's "location". This is a free-form text field, and

there are no guarantees on whether it can be geocoded.

Rendering information

for the author. Colors

are encoded in hex

values (RGB).The creation date

for this account.Whether this account has

contributors enabled

(http://bit.ly/50npuu). Number of

favorites this

user has.

Num

ber

of tw

eets

this

user

has.

Number of

users this user

is following.The timezone and offset

(in seconds) for this user.

The user's selected

language.

Whether this user is protected

or not. If the user is protected,

then this tweet is not visible

except to "friends".

Number of

followers for

this user.

Wheth

er

this

user

has g

eo

enable

d (

http://b

it.ly/4

pF

Y77).

DEPRECATED

in this context

Whether this user

has a verified badge.

The g

eo tag o

n this

tw

eet in

GeoJS

ON

(http://b

it.ly/b

8L1C

p).

The contributors' (if any) user

IDs (http://bit.ly/50npuu).

DEPRECATED

The place associated with this

Tweet (http://bit.ly/b8L1Cp).

The place ID

The URL to fetch a detailed

polygon for this placeThe printable names of this place

The type of this

place - can be a

"neighborhood"

or "city"

The country this place is in

The bounding

box for this

place

The application

that sent this

tweetMap of a Twitter Status Object

Raffi Krikorian <[email protected]>18 April 2010

Page 55: Intro to developing for @twitterapi

{"id"=>12296272736,

"text"=>

"An early look at Annotations:

http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453",

"created_at"=>"Fri Apr 16 17:55:46 +0000 2010",

"in_reply_to_user_id"=>nil,

"in_reply_to_screen_name"=>nil,

"in_reply_to_status_id"=>nil

"favorited"=>false,

"truncated"=>false,

"user"=>

{"id"=>6253282,

"screen_name"=>"twitterapi",

"name"=>"Twitter API",

"description"=>

"The Real Twitter API. I tweet about API changes, service issues and

happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",

"url"=>"http://apiwiki.twitter.com",

"location"=>"San Francisco, CA",

"profile_background_color"=>"c1dfee",

"profile_background_image_url"=>

"http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",

"profile_background_tile"=>false,

"profile_image_url"=>"http://a3.twimg.com/profile_images/689684365/api_normal.png",

"profile_link_color"=>"0000ff",

"profile_sidebar_border_color"=>"87bc44",

"profile_sidebar_fill_color"=>"e0ff92",

"profile_text_color"=>"000000",

"created_at"=>"Wed May 23 06:01:13 +0000 2007",

"contributors_enabled"=>true,

"favourites_count"=>1,

"statuses_count"=>1628,

"friends_count"=>13,

"time_zone"=>"Pacific Time (US & Canada)",

"utc_offset"=>-28800,

"lang"=>"en",

"protected"=>false,

"followers_count"=>100581,

"geo_enabled"=>true,

"notifications"=>false,

"following"=>true,

"verified"=>true},

"contributors"=>[3191321],

"geo"=>nil,

"coordinates"=>nil,

"place"=>

{"id"=>"2b6ff8c22edd9576",

"url"=>"http://api.twitter.com/1/geo/id/2b6ff8c22edd9576.json",

"name"=>"SoMa",

"full_name"=>"SoMa, San Francisco",

"place_type"=>"neighborhood",

"country_code"=>"US",

"country"=>"The United States of America",

"bounding_box"=>

{"coordinates"=>

[[[-122.42284884, 37.76893497],

[-122.3964, 37.76893497],

[-122.3964, 37.78752897],

[-122.42284884, 37.78752897]]],

"type"=>"Polygon"}},

"source"=>"web"}

The tweet's unique ID. These

IDs are roughly sorted &

developers should treat them

as opaque (http://bit.ly/dCkppc).

Text of the tweet.

Consecutive duplicate tweets

are rejected. 140 character

max (http://bit.ly/4ud3he).

Tweet's

creation

date.

DE

PR

EC

AT

ED

The ID of an existing tweet that

this tweet is in reply to. Won't

be set unless the author of the

referenced tweet is mentioned.The screen name &

user ID of replied to

tweet author. Truncated to 140

characters. Only

possible from SMS.

The a

uth

or

of th

e tw

eet. T

his

em

bedded o

bje

ct can g

et out of sync.

The a

uth

or's

user

ID.

The author's

user name.

The author's

screen name.

The author's

biography.

The author's

URL.The author's "location". This is a free-form text field, and

there are no guarantees on whether it can be geocoded.

Rendering information

for the author. Colors

are encoded in hex

values (RGB).The creation date

for this account.Whether this account has

contributors enabled

(http://bit.ly/50npuu). Number of

favorites this

user has.

Num

ber

of tw

eets

this

user

has.

Number of

users this user

is following.The timezone and offset

(in seconds) for this user.

The user's selected

language.

Whether this user is protected

or not. If the user is protected,

then this tweet is not visible

except to "friends".

Number of

followers for

this user.

Wheth

er

this

user

has g

eo

enable

d (

http://b

it.ly/4

pF

Y77).

DEPRECATED

in this context

Whether this user

has a verified badge.

The g

eo tag o

n this

tw

eet in

GeoJS

ON

(http://b

it.ly/b

8L1C

p).

The contributors' (if any) user

IDs (http://bit.ly/50npuu).

DEPRECATED

The place associated with this

Tweet (http://bit.ly/b8L1Cp).

The place ID

The URL to fetch a detailed

polygon for this placeThe printable names of this place

The type of this

place - can be a

"neighborhood"

or "city"

The country this place is in

The bounding

box for this

place

The application

that sent this

tweetMap of a Twitter Status Object

Raffi Krikorian <[email protected]>18 April 2010

Page 56: Intro to developing for @twitterapi

{"id"=>12296272736,

"text"=>

"An early look at Annotations:

http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453",

"created_at"=>"Fri Apr 16 17:55:46 +0000 2010",

"in_reply_to_user_id"=>nil,

"in_reply_to_screen_name"=>nil,

"in_reply_to_status_id"=>nil

"favorited"=>false,

"truncated"=>false,

"user"=>

{"id"=>6253282,

"screen_name"=>"twitterapi",

"name"=>"Twitter API",

"description"=>

"The Real Twitter API. I tweet about API changes, service issues and

happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",

"url"=>"http://apiwiki.twitter.com",

"location"=>"San Francisco, CA",

"profile_background_color"=>"c1dfee",

"profile_background_image_url"=>

"http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",

"profile_background_tile"=>false,

"profile_image_url"=>"http://a3.twimg.com/profile_images/689684365/api_normal.png",

"profile_link_color"=>"0000ff",

"profile_sidebar_border_color"=>"87bc44",

"profile_sidebar_fill_color"=>"e0ff92",

"profile_text_color"=>"000000",

"created_at"=>"Wed May 23 06:01:13 +0000 2007",

"contributors_enabled"=>true,

"favourites_count"=>1,

"statuses_count"=>1628,

"friends_count"=>13,

"time_zone"=>"Pacific Time (US & Canada)",

"utc_offset"=>-28800,

"lang"=>"en",

"protected"=>false,

"followers_count"=>100581,

"geo_enabled"=>true,

"notifications"=>false,

"following"=>true,

"verified"=>true},

"contributors"=>[3191321],

"geo"=>nil,

"coordinates"=>nil,

"place"=>

{"id"=>"2b6ff8c22edd9576",

"url"=>"http://api.twitter.com/1/geo/id/2b6ff8c22edd9576.json",

"name"=>"SoMa",

"full_name"=>"SoMa, San Francisco",

"place_type"=>"neighborhood",

"country_code"=>"US",

"country"=>"The United States of America",

"bounding_box"=>

{"coordinates"=>

[[[-122.42284884, 37.76893497],

[-122.3964, 37.76893497],

[-122.3964, 37.78752897],

[-122.42284884, 37.78752897]]],

"type"=>"Polygon"}},

"source"=>"web"}

The tweet's unique ID. These

IDs are roughly sorted &

developers should treat them

as opaque (http://bit.ly/dCkppc).

Text of the tweet.

Consecutive duplicate tweets

are rejected. 140 character

max (http://bit.ly/4ud3he).

Tweet's

creation

date.

DE

PR

EC

AT

ED

The ID of an existing tweet that

this tweet is in reply to. Won't

be set unless the author of the

referenced tweet is mentioned.The screen name &

user ID of replied to

tweet author. Truncated to 140

characters. Only

possible from SMS.

The a

uth

or

of th

e tw

eet. T

his

em

bedded o

bje

ct can g

et out of sync.

The a

uth

or's

user

ID.

The author's

user name.

The author's

screen name.

The author's

biography.

The author's

URL.The author's "location". This is a free-form text field, and

there are no guarantees on whether it can be geocoded.

Rendering information

for the author. Colors

are encoded in hex

values (RGB).The creation date

for this account.Whether this account has

contributors enabled

(http://bit.ly/50npuu). Number of

favorites this

user has.

Num

ber

of tw

eets

this

user

has.

Number of

users this user

is following.The timezone and offset

(in seconds) for this user.

The user's selected

language.

Whether this user is protected

or not. If the user is protected,

then this tweet is not visible

except to "friends".

Number of

followers for

this user.

Wheth

er

this

user

has g

eo

enable

d (

http://b

it.ly/4

pF

Y77).

DEPRECATED

in this context

Whether this user

has a verified badge.

The g

eo tag o

n this

tw

eet in

GeoJS

ON

(http://b

it.ly/b

8L1C

p).

The contributors' (if any) user

IDs (http://bit.ly/50npuu).

DEPRECATED

The place associated with this

Tweet (http://bit.ly/b8L1Cp).

The place ID

The URL to fetch a detailed

polygon for this placeThe printable names of this place

The type of this

place - can be a

"neighborhood"

or "city"

The country this place is in

The bounding

box for this

place

The application

that sent this

tweetMap of a Twitter Status Object

Raffi Krikorian <[email protected]>18 April 2010

Page 57: Intro to developing for @twitterapi

The fields you really need‣ id - the unique identifier for the status

‣ text - the content of the status update

‣ created_at - the date the status was created at

‣ user/id - the unique identifier for the status creator

‣ user/screen_name - the name of the status creator

‣ user/profile_image_url - the URL to the creator’s avatar

Page 58: Intro to developing for @twitterapi

User objectsThe “who”

Page 59: Intro to developing for @twitterapi

Getting an user object‣ You can do this with a screen name or an ID

‣ Construct the URL for users/show

‣ Grab it!

‣ (and, status objects do have embedded users)

Page 61: Intro to developing for @twitterapi

Taking a look at user @raffi[raffi@tw-mbp13-raffi Desktop]$ curl http://api.twitter.com/1/users/show/raffi.xml<?xml version="1.0" encoding="UTF-8"?><user> <id>8285392</id> <name>raffi</name> <screen_name>raffi</screen_name> <location>San Francisco, California</location> <description>Tinkering, writing, engineering, and breaking things on the @twitterapi.</description> <profile_image_url>http://a1.twimg.com/profile_images/364041028/raffi-headshot-casual_normal.png</profile_image_url> <url>http://www.mehack.com/</url> <protected>false</protected> <followers_count>2862</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>424</friends_count> <created_at>Sun Aug 19 14:24:06 +0000 2007</created_at> <favourites_count>45</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273278095/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications></notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following></following> <statuses_count>2374</statuses_count> <lang>en</lang> <contributors_enabled>false</contributors_enabled> <status> <created_at>Tue May 11 02:24:33 +0000 2010</created_at> <id>13763485927</id> <text>@precipice woot!</text> <source>web</source> <truncated>false</truncated> <in_reply_to_status_id>13763157270</in_reply_to_status_id> <in_reply_to_user_id>236</in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name>precipice</in_reply_to_screen_name> <geo/> <coordinates/> <place xmlns:georss="http://www.georss.org/georss"> <id>ece7b97d252718cc</id> <name>Kings Cross</name> <full_name>Kings Cross, London</full_name> <place_type>neighborhood</place_type> <url>http://api.twitter.com/1/geo/id/ece7b97d252718cc.json</url> <bounding_box> <georss:polygon>51.529151 -0.12884 51.529151 -0.117029 51.535462 -0.117029 51.535462 -0.12884</georss:polygon> </bounding_box> <country code="GB">United Kingdom</country> <street_address></street_address> </place> <contributors/> </status></user>

Page 62: Intro to developing for @twitterapi

The fields you really need‣ id - the unique identifier for the user

‣ screen_name - the screen name of the user

‣ name - the name the user entered on his/her settings page

‣ profile_image_url - the URL to the creator’s avatar

‣ description - the description the user entered on his/her settings page

‣ url - the URL the user entered on his/her settings page

Page 63: Intro to developing for @twitterapi

TimelinesGetting lots of tweets

Page 64: Intro to developing for @twitterapi

Timelines‣ “Arrays” or “lists” of Tweets

‣ in XML, wrapped with <statuses>...</statuses>

‣ in JSON, regular array [...]

‣ Sorted (mostly) chronologically (hence “timeline”)

‣ When statuses are created in the system, they are fanned-out to timelines

Page 65: Intro to developing for @twitterapi

Few different timelines for the user‣ user_timeline - all the tweets you created

‣ friends_timeline - all the tweets that people you follow have created (sans native RTs)

‣ home_timeline - next generation friends_timeline in that it contains native RTs

‣ mentions - all tweets that @mention you

‣ Some don’t require authentication and some do

Page 66: Intro to developing for @twitterapi

Taking a look at @raffi’s user_timeline[raffi@tw-mbp13-raffi twurl (master)]$ curl http://api.twitter.com/1/statuses/user_timeline/raffi.xml<?xml version="1.0" encoding="UTF-8"?><statuses type="array"><status> <created_at>Tue May 11 02:24:33 +0000 2010</created_at> <id>13763485927</id> <text>@precipice woot!</text> <source>web</source> <truncated>false</truncated> <in_reply_to_status_id>13763157270</in_reply_to_status_id> <in_reply_to_user_id>236</in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name>precipice</in_reply_to_screen_name> <user> <id>8285392</id> <name>raffi</name> <screen_name>raffi</screen_name> <location>San Francisco, California</location> <description>Tinkering, writing, engineering, and breaking things on the @twitterapi.</description> <profile_image_url>http://a1.twimg.com/profile_images/364041028/raffi-headshot-casual_normal.png</profile_image_url> <url>http://www.mehack.com/</url> <protected>false</protected> <followers_count>2861</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>424</friends_count> <created_at>Sun Aug 19 14:24:06 +0000 2007</created_at> <favourites_count>45</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273278095/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>true</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>true</following> <statuses_count>2374</statuses_count> <lang>en</lang> <contributors_enabled>false</contributors_enabled> </user> <geo/> <coordinates/> <place xmlns:georss="http://www.georss.org/georss"> <id>ece7b97d252718cc</id> <name>Kings Cross</name>

Page 67: Intro to developing for @twitterapi

Using skip_user to save bandwidth

[raffi@tw-mbp13-raffi twurl (master)]$ curl http://api.twitter.com/1/statuses/user_timeline/raffi.xml?skip_user=true<?xml version="1.0" encoding="UTF-8"?><statuses type="array"><status> <created_at>Tue May 11 02:24:33 +0000 2010</created_at> <id>13763485927</id> <text>@precipice woot!</text> <source>web</source> <truncated>false</truncated> <in_reply_to_status_id>13763157270</in_reply_to_status_id> <in_reply_to_user_id>236</in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name>precipice</in_reply_to_screen_name> <user> <id>8285392</id> </user> <geo/> <coordinates/> <place xmlns:georss="http://www.georss.org/georss"> <id>ece7b97d252718cc</id> <name>Kings Cross</name> <full_name>Kings Cross, London</full_name> <place_type>neighborhood</place_type> <url>http://api.twitter.com/1/geo/id/ece7b97d252718cc.json</url> <bounding_box> <georss:polygon>51.529151 -0.12884 51.529151 -0.117029 51.535462 -0.117029 51.535462 -0.12884</georss:polygon> </bounding_box> <country code="GB">United Kingdom</country> <street_address></street_address> </place> <contributors/></status>

‣ Only user/id - have to lookup user data through other means

Page 68: Intro to developing for @twitterapi

POSTing to the APICausing change

Page 69: Intro to developing for @twitterapi

TweetingLetting the world know your thoughts

Page 70: Intro to developing for @twitterapi

status/update‣ Just POST with a status parameter - that’s it!

[raffi@tw-mbp13-raffi twurl (master)]$ ./bin/twurl -d "status=hey ho" /statuses/update.xml<?xml version="1.0" encoding="UTF-8"?><status> <created_at>Tue May 11 03:39:42 +0000 2010</created_at> <id>13767250371</id> <text>hey ho</text> <source>&lt;a href=&quot;http://www.mehack.com&quot; rel=&quot;nofollow&quot;&gt;Background image uploading example&lt;/a&gt;</source> <truncated>false</truncated> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name></in_reply_to_screen_name> <user> <id>8307492</id> <name>raffibot</name> <screen_name>raffibot</screen_name> <location>Doing the robot!</location> <description></description> <profile_image_url>http://a3.twimg.com/profile_images/637865751/raffibot_normal.jpg</profile_image_url> <url></url> <protected>false</protected> <followers_count>16</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>1</friends_count> <created_at>Mon Aug 20 15:06:07 +0000 2007</created_at> <favourites_count>0</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273001482/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>false</following> <statuses_count>129</statuses_count> <lang>en</lang> <contributors_enabled>true</contributors_enabled> </user> <geo/> <coordinates/> <place/> <contributors/></status>

Page 71: Intro to developing for @twitterapi

Following peopleSubscribing to people to get content

Page 72: Intro to developing for @twitterapi

friendships/create‣ Just POST with a id parameter - that’s it!

[raffi@tw-mbp13-raffi twurl (master)]$ ./bin/twurl -d "id=3191321" /friendships/create.xml<?xml version="1.0" encoding="UTF-8"?><user> <id>3191321</id> <name>Marcel Molina</name> <screen_name>noradio</screen_name> <location>San Francisco, CA</location> <description>Engineer at Twitter on the @twitterapi team obsessed with running. In a past life I was a member of the Rails Core team &amp; 37signals.</description> <profile_image_url>http://a3.twimg.com/profile_images/53473799/marcel-euro-rails-conf_normal.jpg</profile_image_url> <url>http://project.ioni.st</url> <protected>false</protected> <followers_count>288034</followers_count> <profile_background_color>9AE4E8</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDFFCC</profile_sidebar_fill_color> <profile_sidebar_border_color>BDDCAD</profile_sidebar_border_color> <friends_count>494</friends_count> <created_at>Mon Apr 02 07:47:28 +0000 2007</created_at> <favourites_count>299</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://a1.twimg.com/profile_background_images/18156348/jessica_tiled.jpg.jpeg</profile_background_image_url> <profile_background_tile>true</profile_background_tile> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>true</following> <statuses_count>4139</statuses_count> <lang>en</lang> <contributors_enabled>false</contributors_enabled> <status> <created_at>Mon May 10 17:45:17 +0000 2010</created_at> <id>13739196470</id> <text>After struggling on a hot 13 miler in Houston yesterday I find it increasingly hard to believe people run 10x that in Death Valley.</text> <source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source> <truncated>false</truncated> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name></in_reply_to_screen_name> <geo xmlns:georss="http://www.georss.org/georss"> <georss:point>29.72333742 -95.38604265</georss:point> </geo> <coordinates xmlns:georss="http://www.georss.org/georss"> <georss:point>29.72333742 -95.38604265</georss:point> </coordinates> <place xmlns:georss="http://www.georss.org/georss"> <id>27caeb21844a27c7</id> <name>The Museum District</name> <full_name>The Museum District, Houston</full_name> <place_type>neighborhood</place_type> <url>http://api.twitter.com/1/geo/id/27caeb21844a27c7.json</url> <bounding_box> <georss:polygon>29.718544 -95.399573 29.718544 -95.370416 29.734828 -95.370416 29.734828 -95.399573</georss:polygon> </bounding_box> <country code="US">The United States of America</country> <street_address></street_address> </place> <contributors/> </status></user>[raffi@tw-mbp13-raffi twurl (master)]$

Page 73: Intro to developing for @twitterapi

DMing peopleTweeting to one, instead of tweeting to many

Page 74: Intro to developing for @twitterapi

direct_messages/new‣ Just POST with a text and user parameter - that’s it!

[raffi@tw-mbp13-raffi twurl (master)]$ ./bin/twurl -d "text=yo&user=raffi" /direct_messages/new.xml<?xml version="1.0" encoding="UTF-8"?><direct_message> <id>1118562319</id> <sender_id>8307492</sender_id> <text>yo</text> <recipient_id>8285392</recipient_id> <created_at>Tue May 11 03:53:25 +0000 2010</created_at> <sender_screen_name>raffibot</sender_screen_name> <recipient_screen_name>raffi</recipient_screen_name> <sender> <id>8307492</id> <name>raffibot</name> <screen_name>raffibot</screen_name> <location>Doing the robot!</location> <description></description> <profile_image_url>http://a3.twimg.com/profile_images/637865751/raffibot_normal.jpg</profile_image_url> <url></url> <protected>false</protected> <followers_count>16</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>2</friends_count> <created_at>Mon Aug 20 15:06:07 +0000 2007</created_at> <favourites_count>0</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273001482/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>false</following> <statuses_count>129</statuses_count> <lang>en</lang> <contributors_enabled>true</contributors_enabled> </sender> <recipient> <id>8285392</id> <name>raffi</name> <screen_name>raffi</screen_name> <location>San Francisco, California</location> <description>Tinkering, writing, engineering, and breaking things on the @twitterapi.</description> <profile_image_url>http://a1.twimg.com/profile_images/364041028/raffi-headshot-casual_normal.png</profile_image_url> <url>http://www.mehack.com/</url> <protected>false</protected> <followers_count>2863</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>424</friends_count> <created_at>Sun Aug 19 14:24:06 +0000 2007</created_at> <favourites_count>45</favourites_count> <utc_offset>-28800</utc_offset> <time_zone>Pacific Time (US &amp; Canada)</time_zone> <profile_background_image_url>http://s.twimg.com/a/1273278095/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>true</following> <statuses_count>2374</statuses_count> <lang>en</lang> <contributors_enabled>false</contributors_enabled> </recipient></direct_message>

Page 75: Intro to developing for @twitterapi

Search APISifting through large amounts of Tweets

Page 76: Intro to developing for @twitterapi

Search API‣ History

‣ Summize was purchased in 2008

‣ built their own real-time search engine

‣ Still a separate system from main Twitter stack

‣ separate database and indices (only goes back 10-14 days)

‣ different representations of data

‣ different overall status object

‣ different user IDs

‣ different output formats (Atom, instead of XML, and JSON)

‣ Search is a corpus of best quality Tweets

Page 77: Intro to developing for @twitterapi

Running a simple query

[raffi@tw-mbp13-raffi twurl (master)]$ curl http://search.twitter.com/search.atom?q=leeds<?xml version="1.0" encoding="UTF-8"?><feed xmlns:google="http://base.google.com/ns/1.0" xml:lang="en-US" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/"> ... <entry> <id>tag:search.twitter.com,2005:13779639419</id> <published>2010-05-11T09:42:53Z</published> <link type="text/html" href="http://twitter.com/Naomi631/statuses/13779639419" rel="alternate"/> <title>Uniqua brand provides full package to design a website: Web Design Leeds helps in designing a website to stay in t... http://bit.ly/a6Ux3f</title> <content type="html">Uniqua brand provides full package to design a website: Web Design &lt;b&gt;Leeds&lt;/b&gt; helps in designing a website to stay in t... &lt;a href=&quot;http://bit.ly/a6Ux3f&quot;&gt;http://bit.ly/a6Ux3f&lt;/a&gt;</content> <updated>2010-05-11T09:42:53Z</updated> <link type="image/png" href="http://s.twimg.com/a/1273278095/images/default_profile_6_normal.png" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitterfeed.com&quot; rel=&quot;nofollow&quot;&gt;twitterfeed&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Naomi631 (Naomi )</name> <uri>http://twitter.com/Naomi631</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779621510</id> <published>2010-05-11T09:42:18Z</published> <link type="text/html" href="http://twitter.com/TheCourtyard/statuses/13779621510" rel="alternate"/> <title>RT @GatPhilpotts: new range of Cookies, Tiffin &amp; Brownies exclusive to Philpotts (outside of London) will be on sale in our B'ham &amp; Leeds stores today :-)</title> <content type="html">RT &lt;a href=&quot;http://twitter.com/GatPhilpotts&quot;&gt;@GatPhilpotts&lt;/a&gt;: new range of Cookies, Tiffin &amp;amp; Brownies exclusive to Philpotts (outside of London) will be on sale in our B&amp;apos;ham &amp;amp; &lt;b&gt;Leeds&lt;/b&gt; stores today :-)</content> <updated>2010-05-11T09:42:18Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/721547137/The_Courtyard_Helsby-The_Loft-030807__1_aw_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.tweetdeck.com&quot; rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>TheCourtyard (The Courtyard Helsby)</name> <uri>http://twitter.com/TheCourtyard</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779621201</id> <published>2010-05-11T09:42:17Z</published> <link type="text/html" href="http://twitter.com/PRLeedsmetSU/statuses/13779621201" rel="alternate"/> <title>CORRECTION If you're in Leeds tomorrow come to Briggate and make a pledge with @boyshouldcry @Rethink http://ow.ly/1Ju8w #Ballstostigma</title> <content type="html">CORRECTION If you&amp;apos;re in &lt;b&gt;Leeds&lt;/b&gt; tomorrow come to Briggate and make a pledge with &lt;a href=&quot;http://twitter.com/boyshouldcry&quot;&gt;@boyshouldcry&lt;/a&gt; &lt;a href=&quot;http://twitter.com/Rethink&quot;&gt;@Rethink&lt;/a&gt; &lt;a href=&quot;http://ow.ly/1Ju8w&quot;&gt;http://ow.ly/1Ju8w&lt;/a&gt; &lt;a href=&quot;http://search.twitter.com/search?q=%23Ballstostigma&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#Ballstostigma');&quot;&gt;#Ballstostigma&lt;/a&gt;</content> <updated>2010-05-11T09:42:17Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/546200255/pr_logo_v2_normal.JPG" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.hootsuite.com&quot; rel=&quot;nofollow&quot;&gt;HootSuite&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>PRLeedsmetSU (Leeds Met SU )</name> <uri>http://twitter.com/PRLeedsmetSU</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779620241</id> <published>2010-05-11T09:42:16Z</published> <link type="text/html" href="http://twitter.com/AdamBurnsPR/statuses/13779620241" rel="alternate"/> <title>CORRECTION If you're in Leeds tomorrow come to Briggate and make a pledge with @boyshouldcry @Rethink http://ow.ly/1Ju8u #Ballstostigma</title> <content type="html">CORRECTION If you&amp;apos;re in &lt;b&gt;Leeds&lt;/b&gt; tomorrow come to Briggate and make a pledge with &lt;a href=&quot;http://twitter.com/boyshouldcry&quot;&gt;@boyshouldcry&lt;/a&gt; &lt;a href=&quot;http://twitter.com/Rethink&quot;&gt;@Rethink&lt;/a&gt; &lt;a href=&quot;http://ow.ly/1Ju8u&quot;&gt;http://ow.ly/1Ju8u&lt;/a&gt; &lt;a href=&quot;http://search.twitter.com/search?q=%23Ballstostigma&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#Ballstostigma');&quot;&gt;#Ballstostigma&lt;/a&gt;</content> <updated>2010-05-11T09:42:16Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/431439924/me_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.hootsuite.com&quot; rel=&quot;nofollow&quot;&gt;HootSuite&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>AdamBurnsPR (Adam Burns)</name> <uri>http://twitter.com/AdamBurnsPR</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779611952</id> <published>2010-05-11T09:42:00Z</published> <link type="text/html" href="http://twitter.com/TraceRoyal/statuses/13779611952" rel="alternate"/> <title>Uniqua brand provides full package to design a website: Web Design Leeds helps in designing a website to stay in t... http://bit.ly/cDJOAL</title> <content type="html">Uniqua brand provides full package to design a website: Web Design &lt;b&gt;Leeds&lt;/b&gt; helps in designing a website to stay in t... &lt;a href=&quot;http://bit.ly/cDJOAL&quot;&gt;http://bit.ly/cDJOAL&lt;/a&gt;</content> <updated>2010-05-11T09:42:00Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/621016750/average_man_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitterfeed.com&quot; rel=&quot;nofollow&quot;&gt;twitterfeed&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>TraceRoyal (Trace Royal)</name> <uri>http://twitter.com/TraceRoyal</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779609130</id> <published>2010-05-11T09:41:54Z</published> <link type="text/html" href="http://twitter.com/CustomerCareJob/statuses/13779609130" rel="alternate"/> <title>Customer Service Advisors x 50, Leeds http://ff.im/-k9FvK</title> <content type="html">Customer Service Advisors x 50, &lt;b&gt;Leeds&lt;/b&gt; &lt;a href=&quot;http://ff.im/-k9FvK&quot;&gt;http://ff.im/-k9FvK&lt;/a&gt;</content> <updated>2010-05-11T09:41:54Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/317950902/gb_flag_small_normal.gif" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://friendfeed.com&quot; rel=&quot;nofollow&quot;&gt;FriendFeed&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>CustomerCareJob (CustomerCareJob)</name> <uri>http://twitter.com/CustomerCareJob</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779582363</id> <published>2010-05-11T09:41:02Z</published> <link type="text/html" href="http://twitter.com/10batistuta/statuses/13779582363" rel="alternate"/> <title>Leeds United: Leeds ace on verge of u-turn: Simon Grayson has said he hasn't given up hope of losing http://url4.eu/3Jl0H</title> <content type="html">&lt;b&gt;Leeds&lt;/b&gt; United: &lt;b&gt;Leeds&lt;/b&gt; ace on verge of u-turn: Simon Grayson has said he hasn&amp;apos;t given up hope of losing &lt;a href=&quot;http://url4.eu/3Jl0H&quot;&gt;http://url4.eu/3Jl0H&lt;/a&gt;</content> <updated>2010-05-11T09:41:02Z</updated> <link type="image/png" href="http://s.twimg.com/a/1273008894/images/default_profile_4_normal.png" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://rss2twitter.com/&quot; rel=&quot;nofollow&quot;&gt;RSS2Twitter&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>10batistuta (football fan)</name> <uri>http://twitter.com/10batistuta</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779548811</id> <published>2010-05-11T09:39:59Z</published> <link type="text/html" href="http://twitter.com/Capela_Gary/statuses/13779548811" rel="alternate"/> <title>Stayed in Bewleys Hotel, Leeds at weekend - completely packed due to football, service mostly good but one lift out of order all weekend</title> <content type="html">Stayed in Bewleys Hotel, &lt;b&gt;Leeds&lt;/b&gt; at weekend - completely packed due to football, service mostly good but one lift out of order all weekend</content> <updated>2010-05-11T09:39:59Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/774397675/Gary_Grieve_Jun_09_normal.JPG" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Capela_Gary (Gary Grieve)</name> <uri>http://twitter.com/Capela_Gary</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779480306</id> <published>2010-05-11T09:37:42Z</published> <link type="text/html" href="http://twitter.com/bendenison/statuses/13779480306" rel="alternate"/> <title>RT @mikechitty: #Leeds band Hope and Social pursuing the 'long tail' - http://bit.ly/9yEhMC and http://bit.ly/cHNwc #enterprise #creative</title> <content type="html">RT &lt;a href=&quot;http://twitter.com/mikechitty&quot;&gt;@mikechitty&lt;/a&gt;: &lt;a href=&quot;http://search.twitter.com/search?q=%23Leeds&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#Leeds');&quot;&gt;#&lt;b&gt;Leeds&lt;/b&gt;&lt;/a&gt; band Hope and Social pursuing the &amp;apos;long tail&amp;apos; - &lt;a href=&quot;http://bit.ly/9yEhMC&quot;&gt;http://bit.ly/9yEhMC&lt;/a&gt; and &lt;a href=&quot;http://bit.ly/cHNwc&quot;&gt;http://bit.ly/cHNwc&lt;/a&gt; &lt;a href=&quot;http://search.twitter.com/search?q=%23enterprise&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#enterprise');&quot;&gt;#enterprise&lt;/a&gt; &lt;a href=&quot;http://search.twitter.com/search?q=%23creative&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#creative');&quot;&gt;#creative&lt;/a&gt;</content> <updated>2010-05-11T09:37:42Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/658505313/Avatar2_normal.png" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.brizzly.com&quot; rel=&quot;nofollow&quot;&gt;Brizzly&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>bendenison (bendenison)</name> <uri>http://twitter.com/bendenison</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779480025</id> <published>2010-05-11T09:37:42Z</published> <link type="text/html" href="http://twitter.com/bryonyvk/statuses/13779480025" rel="alternate"/> <title>RT @GdnLeeds: In case you missed it - Barcelona bloggers have enjoyed sights and sounds of Leeds, post by @hebemedia's Lee Hicken http://bit.ly/cM6BTQ</title> <content type="html">RT &lt;a href=&quot;http://twitter.com/GdnLeeds&quot;&gt;@GdnLeeds&lt;/a&gt;: In case you missed it - Barcelona bloggers have enjoyed sights and sounds of &lt;b&gt;Leeds&lt;/b&gt;, post by &lt;a href=&quot;http://twitter.com/hebemedia&quot;&gt;@hebemedia&lt;/a&gt;&amp;apos;s Lee Hicken &lt;a href=&quot;http://bit.ly/cM6BTQ&quot;&gt;http://bit.ly/cM6BTQ&lt;/a&gt;</content> <updated>2010-05-11T09:37:42Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/808040282/twitterProfilePhoto_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.tweetdeck.com/&quot; rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>bryonyvk (Bryony Victoria King)</name> <uri>http://twitter.com/bryonyvk</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779468504</id> <published>2010-05-11T09:37:19Z</published> <link type="text/html" href="http://twitter.com/nath_brudenell/statuses/13779468504" rel="alternate"/> <title>@whiskas9 there's some Leeds Uni art/visual thing on tonight in main room, part of final degree thing. a few bands on too. im watching footy</title> <content type="html">&lt;a href=&quot;http://twitter.com/whiskas9&quot;&gt;@whiskas9&lt;/a&gt; there&amp;apos;s some &lt;b&gt;Leeds&lt;/b&gt; Uni art/visual thing on tonight in main room, part of final degree thing. a few bands on too. im watching footy</content> <updated>2010-05-11T09:37:19Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/887215812/473975977_f1578c8f21_m_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>nath_brudenell (Nath Brudenell)</name> <uri>http://twitter.com/nath_brudenell</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779468403</id> <published>2010-05-11T09:37:18Z</published> <link type="text/html" href="http://twitter.com/MisterPtee/statuses/13779468403" rel="alternate"/> <title>@themasterplan85 Yeah so far i am going to leeds. But theres a nasty rumour that i may have to bloody work late friday #gawddammit</title> <content type="html">&lt;a href=&quot;http://twitter.com/themasterplan85&quot;&gt;@themasterplan85&lt;/a&gt; Yeah so far i am going to &lt;b&gt;leeds&lt;/b&gt;. But theres a nasty rumour that i may have to bloody work late friday &lt;a href=&quot;http://search.twitter.com/search?q=%23gawddammit&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#gawddammit');&quot;&gt;#gawddammit&lt;/a&gt;</content> <updated>2010-05-11T09:37:18Z</updated> <link type="image/png" href="http://a1.twimg.com/profile_images/734152044/homer-simpson-elvis_normal.gif" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.snaptu.com/a/twitter&quot; rel=&quot;nofollow&quot;&gt;Snaptu&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>MisterPtee (Mister)</name> <uri>http://twitter.com/MisterPtee</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779453501</id> <published>2010-05-11T09:36:49Z</published> <link type="text/html" href="http://twitter.com/EdnaAndMary/statuses/13779453501" rel="alternate"/> <title>Ooh, marvellous Edna. I've got me pull-along bag &amp; I'm ready to go! Leeds here we come... :) [M]</title> <content type="html">Ooh, marvellous Edna. I&amp;apos;ve got me pull-along bag &amp;amp; I&amp;apos;m ready to go! &lt;b&gt;Leeds&lt;/b&gt; here we come... :) [M]</content> <updated>2010-05-11T09:36:49Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/889088787/twitter_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>EdnaAndMary (Edna And Mary)</name> <uri>http://twitter.com/EdnaAndMary</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779419912</id> <published>2010-05-11T09:35:40Z</published> <link type="text/html" href="http://twitter.com/Brunnhofer/statuses/13779419912" rel="alternate"/> <title>@woodpigeontweet previous happiness for you and your band traveling, eating awesome skyr, getting to see LEEDS (?) now pure jealousy.</title> <content type="html">&lt;a href=&quot;http://twitter.com/woodpigeontweet&quot;&gt;@woodpigeontweet&lt;/a&gt; previous happiness for you and your band traveling, eating awesome skyr, getting to see &lt;b&gt;LEEDS&lt;/b&gt; (?) now pure jealousy.</content> <updated>2010-05-11T09:35:40Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/821222269/8124_576793470307_120606265_34563039_6920632_n_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Brunnhofer (Adele Brunnhofer)</name> <uri>http://twitter.com/Brunnhofer</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13779387807</id> <published>2010-05-11T09:34:36Z</published> <link type="text/html" href="http://twitter.com/EdnaAndMary/statuses/13779387807" rel="alternate"/> <title>We're off for a shop in Leeds today &amp; have found some right good value deals from @GopherDeals at www.gopherdeals.co.uk! [E]</title> <content type="html">We&amp;apos;re off for a shop in &lt;b&gt;Leeds&lt;/b&gt; today &amp;amp; have found some right good value deals from &lt;a href=&quot;http://twitter.com/GopherDeals&quot;&gt;@GopherDeals&lt;/a&gt; at &lt;a href=&quot;http://www.gopherdeals.co.uk&quot;&gt;www.gopherdeals.co.uk&lt;/a&gt;! [E]</content> <updated>2010-05-11T09:34:36Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/889088787/twitter_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>EdnaAndMary (Edna And Mary)</name> <uri>http://twitter.com/EdnaAndMary</uri> </author> </entry></feed>

‣ Just GET with a q parameter - that’s it!

Page 78: Intro to developing for @twitterapi

Advanced operators‣ from - restrict results to tweets from a particular screen name

‣ result_type=popular - find both “best” tweets and temporally relevant tweets

‣ Textual operators

‣ OR to combine queries - http://search.twitter.com/search.atom?q=leeds+OR+london

‣ - to negate - http://search.twitter.com/search.atom?q=leeds+-from%3Aimran

Page 79: Intro to developing for @twitterapi

What @raffi usually does‣ Use the web interface on search.twitter.com to construct the

query

‣ Tweak it and shorten it

‣ Switch the result format to be in API compatible format

‣ Use that!

Page 80: Intro to developing for @twitterapi
Page 81: Intro to developing for @twitterapi
Page 82: Intro to developing for @twitterapi

Trim down the URL‣ http://search.twitter.com/search?q=&ands=leeds+twitter&phrase=&ors=&nots=&tag=&lang=all&from=imran&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=15

‣ Strip down to only where our custom data is

‣ ands - where the query is

‣ from - restrict it to @imran

‣ make the format atom to get an API friendly response

‣ http://search.twitter.com/search.atom?ands=leeds+twitter&from=imran

Page 83: Intro to developing for @twitterapi

Running the custom query[raffi@tw-mbp13-raffi twurl (master)]$ curl "http://search.twitter.com/search.atom?ands=leeds+twitter&from=imran"<?xml version="1.0" encoding="UTF-8"?><feed xmlns:google="http://base.google.com/ns/1.0" xml:lang="en-US" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/"> ... <entry> <id>tag:search.twitter.com,2005:13635764900</id> <published>2010-05-09T00:00:05Z</published> <link type="text/html" href="http://twitter.com/Imran/statuses/13635764900" rel="alternate"/> <title>nosing through @raffi's slides on twitter annotation from @warblecamp&#8230;lookin fwd to his leeds trip on weds! {http://imrn.me/c536Ej} #LSx2010</title> <content type="html">nosing through &lt;a href=&quot;http://twitter.com/raffi&quot;&gt;@raffi&lt;/a&gt;&amp;apos;s slides on &lt;b&gt;twitter&lt;/b&gt; annotation from @warblecamp&#8230;lookin fwd to his &lt;b&gt;leeds&lt;/b&gt; trip on weds! {&lt;a href=&quot;http://imrn.me/c536Ej&quot;&gt;http://imrn.me/c536Ej&lt;/a&gt;} &lt;a href=&quot;http://search.twitter.com/search?q=%23LSx2010&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#LSx2010');&quot;&gt;#LSx2010&lt;/a&gt;</content> <updated>2010-05-09T00:00:05Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/421133727/TEDx_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Imran (Imran Ali)</name> <uri>http://twitter.com/Imran</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13547403421</id> <published>2010-05-07T13:03:33Z</published> <link type="text/html" href="http://twitter.com/Imran/statuses/13547403421" rel="alternate"/> <title>twitter's @raffi will be in leeds next tues afternoon running a free workshop on &quot;developing for twitter&quot; {http://imrn.me/bbHgNT} #LSx2010</title> <content type="html">&lt;b&gt;twitter&lt;/b&gt;&amp;apos;s &lt;a href=&quot;http://twitter.com/raffi&quot;&gt;@raffi&lt;/a&gt; will be in &lt;b&gt;leeds&lt;/b&gt; next tues afternoon running a free workshop on &amp;quot;developing for &lt;b&gt;twitter&lt;/b&gt;&amp;quot; {&lt;a href=&quot;http://imrn.me/bbHgNT&quot;&gt;http://imrn.me/bbHgNT&lt;/a&gt;} &lt;a href=&quot;http://search.twitter.com/search?q=%23LSx2010&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#LSx2010');&quot;&gt;#LSx2010&lt;/a&gt;</content> <updated>2010-05-07T13:03:33Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/421133727/TEDx_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Imran (Imran Ali)</name> <uri>http://twitter.com/Imran</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13504316998</id> <published>2010-05-06T19:37:14Z</published> <link type="text/html" href="http://twitter.com/Imran/statuses/13504316998" rel="alternate"/> <title>wanna meet twitter's @raffi, see 15 @ignite talks or join leeds' 4th barcamp? head over to the #LSx2010 schedule! http://lsx2010.com</title> <content type="html">wanna meet &lt;b&gt;twitter&lt;/b&gt;&amp;apos;s &lt;a href=&quot;http://twitter.com/raffi&quot;&gt;@raffi&lt;/a&gt;, see 15 &lt;a href=&quot;http://twitter.com/ignite&quot;&gt;@ignite&lt;/a&gt; talks or join &lt;b&gt;leeds&lt;/b&gt;&amp;apos; 4th barcamp? head over to the &lt;a href=&quot;http://search.twitter.com/search?q=%23LSx2010&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#LSx2010');&quot;&gt;#LSx2010&lt;/a&gt; schedule! &lt;a href=&quot;http://lsx2010.com&quot;&gt;http://lsx2010.com&lt;/a&gt;</content> <updated>2010-05-06T19:37:14Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/421133727/TEDx_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Imran (Imran Ali)</name> <uri>http://twitter.com/Imran</uri> </author> </entry> <entry> <id>tag:search.twitter.com,2005:13429389361</id> <published>2010-05-05T14:30:06Z</published> <link type="text/html" href="http://twitter.com/Imran/statuses/13429389361" rel="alternate"/> <title>booking a hotel for @raffi's first trip to leeds...details on his &quot;developing for twitter&quot; workshop &amp; keynote to follow :) #LSx2010</title> <content type="html">booking a hotel for &lt;a href=&quot;http://twitter.com/raffi&quot;&gt;@raffi&lt;/a&gt;&amp;apos;s first trip to &lt;b&gt;leeds&lt;/b&gt;...details on his &amp;quot;developing for &lt;b&gt;twitter&lt;/b&gt;&amp;quot; workshop &amp;amp; keynote to follow :) &lt;a href=&quot;http://search.twitter.com/search?q=%23LSx2010&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#LSx2010');&quot;&gt;#LSx2010&lt;/a&gt;</content> <updated>2010-05-05T14:30:06Z</updated> <link type="image/png" href="http://a3.twimg.com/profile_images/421133727/TEDx_normal.jpg" rel="image"/> <twitter:geo> </twitter:geo> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> <twitter:source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</twitter:source> <twitter:lang>en</twitter:lang> <author> <name>Imran (Imran Ali)</name> <uri>http://twitter.com/Imran</uri> </author> </entry></feed>

Page 84: Intro to developing for @twitterapi

Trends APIWhat’s going on right now?

Page 85: Intro to developing for @twitterapi

Trends API‣ Trending topics are used for content discovery - powers the front

page and logged out experience of twitter.com

‣ API provides both global trends and local trends

‣ Timescale

‣ global trends are provided for “now”, and summaries of the past day and week

‣ local trends are only provided for “now”

Page 86: Intro to developing for @twitterapi
Page 87: Intro to developing for @twitterapi
Page 88: Intro to developing for @twitterapi

WOEIDs‣ “Where on Earth Identifiers”

‣ http://developer.yahoo.com/geo/

‣ Provides “stable” and “language neutral” identifiers for places in the world

‣ Twitter has the World (WOEID of 1), and a series of countries and cities in its trends database

Page 89: Intro to developing for @twitterapi

Fetching global trends[raffi@tw-mbp13-raffi twurl (master)]$ curl http://api.twitter.com/1/trends/1/current.xml<?xml version="1.0" encoding="UTF-8"?><matching_trends type="array"> <trends as_of="2010-05-11T10:35:25Z"> <locations> <location> <woeid>1</woeid> <name>Earth</name> </location> </locations> <trend query="Bonamana" url="http://search.twitter.com/search?q=Bonamana">Bonamana</trend> <trend query="%23ausbudget" url="http://search.twitter.com/search?q=%23ausbudget">#ausbudget</trend> <trend query="%231thingaboutme" url="http://search.twitter.com/search?q=%231thingaboutme">#1thingaboutme</trend> <trend query="%23damnitstrue" url="http://search.twitter.com/search?q=%23damnitstrue">#damnitstrue</trend> <trend query="Binay" url="http://search.twitter.com/search?q=Binay">Binay</trend> <trend query="Boulton" url="http://search.twitter.com/search?q=Boulton">Boulton</trend> <trend query="Kagan" url="http://search.twitter.com/search?q=Kagan">Kagan</trend> <trend query="Zola" url="http://search.twitter.com/search?q=Zola">Zola</trend> <trend query="McClaren" url="http://search.twitter.com/search?q=McClaren">McClaren</trend> <trend query="Clegg" url="http://search.twitter.com/search?q=Clegg">Clegg</trend> </trends></matching_trends>

Page 90: Intro to developing for @twitterapi

Finding locations that have trends[raffi@tw-mbp13-raffi twurl (master)]$ curl http://api.twitter.com/1/trends/available.xml<?xml version="1.0" encoding="UTF-8"?><locations type="array"><location> <woeid>23424900</woeid> <name>Mexico</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="MX">Mexico</country> <url>http://where.yahooapis.com/v1/place/23424900</url></location><location> <woeid>23424803</woeid> <name>Ireland</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="IE">Ireland</country> <url>http://where.yahooapis.com/v1/place/23424803</url></location><location> <woeid>23424975</woeid> <name>United Kingdom</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="GB">United Kingdom</country> <url>http://where.yahooapis.com/v1/place/23424975</url></location><location> <woeid>455827</woeid> <name>Sao Paulo</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="BR">Brazil</country> <url>http://where.yahooapis.com/v1/place/455827</url></location><location> <woeid>2358820</woeid> <name>Baltimore</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2358820</url></location><location> <woeid>2367105</woeid> <name>Boston</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2367105</url></location><location> <woeid>2514815</woeid> <name>Washington</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2514815</url></location><location> <woeid>2459115</woeid> <name>New York</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2459115</url></location><location> <woeid>2487796</woeid> <name>San Antonio</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2487796</url></location><location> <woeid>23424977</woeid> <name>United States</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/23424977</url></location><location> <woeid>2379574</woeid> <name>Chicago</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2379574</url></location><location> <woeid>2471217</woeid> <name>Philadelphia</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2471217</url></location><location> <woeid>23424768</woeid> <name>Brazil</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="BR">Brazil</country> <url>http://where.yahooapis.com/v1/place/23424768</url></location><location> <woeid>2487956</woeid> <name>San Francisco</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2487956</url></location><location> <woeid>2442047</woeid> <name>Los Angeles</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2442047</url></location><location> <woeid>2424766</woeid> <name>Houston</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2424766</url></location><location> <woeid>23424775</woeid> <name>Canada</name> <placeTypeName code="12">Country</placeTypeName> <country type="Country" code="CA">Canada</country> <url>http://where.yahooapis.com/v1/place/23424775</url></location><location> <woeid>2357024</woeid> <name>Atlanta</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2357024</url></location><location> <woeid>2406080</woeid> <name>Fort Worth</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2406080</url></location><location> <woeid>2388929</woeid> <name>Dallas</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2388929</url></location><location> <woeid>2490383</woeid> <name>Seattle</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="US">United States</country> <url>http://where.yahooapis.com/v1/place/2490383</url></location><location> <woeid>44418</woeid> <name>London</name> <placeTypeName code="7">Town</placeTypeName> <country type="Country" code="GB">United Kingdom</country> <url>http://where.yahooapis.com/v1/place/44418</url></location><location> <woeid>1</woeid> <name>Earth</name> <placeTypeName code="19">Supername</placeTypeName> <country/> <url>http://where.yahooapis.com/v1/place/1</url></location></locations>

Page 91: Intro to developing for @twitterapi

Locations that have trends now‣ Earth (1)

‣ Countries - Mexico (23424900), Ireland (23424803), United Kingdom (23424975), United States (23424977), Brazil (23424768), Canada (23424775)

‣ Cities - Sao Paulo (455827), Baltimore (2358820), Boston (2367105), Washington (2514815), New York (2459115), San Antonio (2487796), Chicago (2379574), Philadelphia (2471217), San Francisco (2487956), Los Angeles (2442047), Houston (2424766), Atlanta (2357024), Fort Worth (2406080), Dallas (2388929), Seattle (2490383), London (44418)

Page 92: Intro to developing for @twitterapi

Fetching trends for London[raffi@tw-mbp13-raffi twurl (master)]$ curl http://api.twitter.com/1/trends/44418/current.xml<?xml version="1.0" encoding="UTF-8"?><matching_trends type="array"> <trends as_of="2010-05-11T10:43:26Z"> <locations> <location> <woeid>44418</woeid> <name>London</name> </location> </locations> <trend query="Malcolm+Rifkind" url="http://search.twitter.com/search?q=Malcolm+Rifkind">Malcolm Rifkind</trend> <trend query="%23ukelection" url="http://search.twitter.com/search?q=%23ukelection">#ukelection</trend> <trend query="%231thingaboutme" url="http://search.twitter.com/search?q=%231thingaboutme">#1thingaboutme</trend> <trend query="%23bottomlineis" url="http://search.twitter.com/search?q=%23bottomlineis">#bottomlineis</trend> <trend query="Adam+Boulton" url="http://search.twitter.com/search?q=Adam+Boulton">Adam Boulton</trend> <trend query="Lib-Lab" url="http://search.twitter.com/search?q=Lib-Lab">Lib-Lab</trend> <trend query="Bilic" url="http://search.twitter.com/search?q=Bilic">Bilic</trend> <trend query="FPTP" url="http://search.twitter.com/search?q=FPTP">FPTP</trend> <trend query="Junior+Apprentice" url="http://search.twitter.com/search?q=Junior+Apprentice">Junior Apprentice</trend> <trend query="Blunkett" url="http://search.twitter.com/search?q=Blunkett">Blunkett</trend> </trends></matching_trends>

Page 93: Intro to developing for @twitterapi

Streaming APII need it now, now, now, now, now

Page 94: Intro to developing for @twitterapi

Streaming API‣ Maintain a persistent connection to servers

‣ Get pushed a tweet that matches your predicate in “real-time”

‣ Most useful for server to server integrations

‣ Beginning to experiment with server to client integrations

Page 95: Intro to developing for @twitterapi

Get a sample of all the tweets‣ Use curl for a really simple proof-of-concept client

‣ http://stream.twitter.com/1/statuses/sample.xml

‣ Requires basic authorization (username and password)

‣ Only one connection per usernamehttp://stream.twitter.com/1/statuses/sample.xml

Page 96: Intro to developing for @twitterapi

Get the tweets from certain users‣ http://stream.twitter.com/1/statuses/filter.xml

‣ Can pass in a list of user IDs

‣ up to 400 users (passed as follow with CSV IDs)

‣ get their tweets as they are getting created

Page 97: Intro to developing for @twitterapi

Get the tweets containing a certain word‣ http://stream.twitter.com/1/statuses/filter.xml

‣ Can pass in a list of words

‣ up to 200 users (passed as track with CSV IDs)

‣ e.g. Twitter will match TWITTER, twitter, “Twitter”, twitter., #twitter, and @twitter

‣ get tweets as they are getting created

Page 98: Intro to developing for @twitterapi

The team

Page 99: Intro to developing for @twitterapi

Questions? Follow me attwitter.com/raffi

TM