6. What is ?
The Twitter Platform
TM
Saturday, July 24, 2010
7. What is ?
‣ REST API
‣ provides the “basic” Twitter 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 TM
Saturday, July 24, 2010
8. 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
‣ No duplicate tweets
‣ No malware links in tweets TM
Saturday, July 24, 2010
9. dev.twitter.com
The developer portal
TM
Saturday, July 24, 2010
10. Creating an app
Your own small playground
TM
Saturday, July 24, 2010
18. OAuthpocalypse
The day is 30th June 16th August 2010
TM
Saturday, July 24, 2010
19. What you need to know
‣ All applications must be using OAuth for the REST API
‣ Streaming API will still support Basic Auth
‣ Search API has no auth
‣ Replace curl with twurl for debugging
http://dev.twitter.com/pages/auth_overview
http://github.com/marcel/twurl
TM
Saturday, July 24, 2010
20. OAuth Methods
‣ Web must use three legged OAuth
‣ Desktop and mobile apps can also use out-of-band OAuth
‣ Some desktop and mobile apps will be considered for xAuth
TM
Saturday, July 24, 2010
21. xAuth not XAuth
xAuth is OAuth
http://dev.twitter.com/pages/xauth
TM
Saturday, July 24, 2010
22. Check your host!
api.twitter.com
twitter.com
TM
Saturday, July 24, 2010
24. twurl
‣ http://github.com/marcel/twurl
‣ Command line tool to interact with using OAuth
‣ Transparently handles OAuth signing against
‣ POST and GET data
‣ Trace requests
TM
Saturday, July 24, 2010
32. Create a place
‣ /1/geo/search
‣ show what’s nearby
‣ /1/geo/similar_places
‣ not found in search, find by name
‣ /1/geo/place
‣ still not found, create a new place
http://api.twitter.com/1/geo/place
TM
Saturday, July 24, 2010
50. More Info... Check out
bit.ly/anywhere-begin
TM
Saturday, July 24, 2010
51. Bridge Code
@anywhere to api.twitter.com
TM
Saturday, July 24, 2010
52. Overview
‣ Use connect with Twitter
‣ Hook into authComplete
‣ Send the bridge code to your server
‣ Exchange the bridge code using /oauth/access_token
‣ Verify
TM
Saturday, July 24, 2010
53. Use connect with Twitter
T("#connect-placeholder").connectButton({
authComplete: function(user, bridge_code) {
$.post('/mypage.php', {
'bridge_code' : bridge_code
});
}
});
TM
Saturday, July 24, 2010
56. Send to your server
T("#connect-placeholder").connectButton({
authComplete: function(user, bridge_code) {
$.post('/mypage.php', {
'bridge_code' : bridge_code
});
}
});
TM
Saturday, July 24, 2010
57. Exchange the bridge code
‣ POST to https://api.twitter.com/oauth/access_token
‣ Parameter is oauth_bridge_code
‣ Sign with your applications consumer token and secret
TM
Saturday, July 24, 2010
58. Exchange the token - PHP
$http->request(
'POST',
'https://api.twitter.com/oauth/access_token', array(
'oauth_bridge_code' => $_REQUEST['bridge_code']
)
);
TM
Saturday, July 24, 2010
59. Verify
‣ Using the user tokens call
/1/account/verify_credentials.json
‣ Generate the signature
sha1( user_id + consumer_secret )
‣ Compare the signature with the cookie value in
twitter_anywhere_identity
TM
Saturday, July 24, 2010
60. Streaming API
Near-Realtime Access to Public Statuses
TM
Saturday, July 24, 2010
61. Streaming API
‣ A persistent connection to Twitter servers
‣ Get pushed a tweet that matches your predicate in “real-time”
‣ Server to server integrations
TM
Saturday, July 24, 2010
62. Basic Usage
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
http://stream.twitter.com/1/statuses/sample.json
TM
Saturday, July 24, 2010
63. Follow some users
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
‣ Pass up to 400 user_ids, comma seperated
http://stream.twitter.com/1/statuses/filter.json
TM
Saturday, July 24, 2010
64. Filter by keyword
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
‣ Pass up to 200 keywords, comma seperated
‣ Example: Twitter will return statuses which contain: TWITTER,
twitter, "Twitter", twitter., #twitter and @twitter
http://stream.twitter.com/1/statuses/filter.json
TM
Saturday, July 24, 2010
65. Streaming API - Default Level
‣ 200 x Keywords
‣ 400 x Follow userids
‣ 10 x 1-degree location boxes
TM
Saturday, July 24, 2010
66. More Info... Check out
bit.ly/streaming_api
TM
Saturday, July 24, 2010
67. 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
Saturday, July 24, 2010
68. Help... Check out
dev.twitter.com
TM
Saturday, July 24, 2010
69. Questions? Follow us at
twitter.com/twitterapi
twitter.com/themattharris
TM
Saturday, July 24, 2010