@twitterapi at SocialApp Workshop

Post on 19-May-2015

5.627 views 1 download

Tags:

description

Presented 24 July 2010 at the Heroku Offices, San Francisco

Transcript of @twitterapi at SocialApp Workshop

TM

Saturday, July 24, 2010

TM

@twitterapi

@herokuJuly 24, 2010

#appworkshop @themattharris @heroku

Saturday, July 24, 2010

TM

About us

Saturday, July 24, 2010

TM

The team

Saturday, July 24, 2010

TM

@themattharrisAbout me

Saturday, July 24, 2010

TM

What is ? The Twitter Platform

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

dev.twitter.comThe developer portal

Saturday, July 24, 2010

TM

Creating an appYour own small playground

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

Browsing docs

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

Saturday, July 24, 2010

TM

OAuthpocalypseThe day is 30th June 16th August 2010

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

xAuth not XAuth

xAuth is OAuth

http://dev.twitter.com/pages/xauth

Saturday, July 24, 2010

TM

Check your host!

api.twitter.com

twitter.com

Saturday, July 24, 2010

TM

Libraries

http://dev.twitter.com/pages/oauth_libraries

ActionScript/FlashC/C++C#/.NETClojureErlangJavaJavaScript

Objective-C/Cocoa & iPhone ProgrammingPerlPHPPythonQtRubyScala

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

Timelines

Saturday, July 24, 2010

TM

Timeline Endpoints‣ /1/statuses/public_timeline

‣ /1/statuses/home_timeline

‣ /1/statuses/friends_timeline

‣ /1/statuses/user_timeline

‣ /1/statuses/mentions

‣ /1/statuses/retweeted_by_me

‣ /1/statuses/retweeted_to_me

‣ /1/statuses/retweets_of_me

Saturday, July 24, 2010

TM

Modifiers‣ include_rts

Accepted values: true, 1, t

Saturday, July 24, 2010

TM

Modifiers‣ include_rts

‣ include_entities

Accepted values: true, 1, t

Saturday, July 24, 2010

TM

Modifiers‣ include_rts

‣ include_entities

‣ trim_user

Accepted values: true, 1, t

Saturday, July 24, 2010

TM

Geo

Saturday, July 24, 2010

TM

Endpoints‣ /1/geo/search

‣ /1/geo/similar_places

‣ /1/geo/reverse_geocode

‣ /1/geo/id/:id

‣ /1/geo/place

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

Get location (if allowed)

Saturday, July 24, 2010

TM

Get location (if allowed)

Saturday, July 24, 2010

TM

/1/geo/search - suggest nearby

Saturday, July 24, 2010

TM

/1/geo/search - suggest nearby

Saturday, July 24, 2010

TM

/1/geo/similar_places - find by name

Saturday, July 24, 2010

TM

/1/geo/similar_places - find by name

Saturday, July 24, 2010

TM

/1/geo/place - not it? create it

Saturday, July 24, 2010

TM

Technical Info ...‣ /1/geo/similar_places

‣ must run this first to get a creation_token

Saturday, July 24, 2010

TM

Technical Info ...                ],                "full_name":  "Twitter  HQ,  San  Francisco",                "place_type":  "poi"            }        ],        "token":  "36179c9bf78835898ebf521c1defd4be"    },    "query":  {        "url":  "http://api.twitter.com/1/geo/similar_places.json?query=&contained_within=&lat=37.7821120598956&accuracy=&autocomplete=&long=-­‐122.400612831116&granularity=&name=Twitter",        "type":  "similar_places",

Saturday, July 24, 2010

TM

More Info... Check outbit.ly/twitter-api-geo

Saturday, July 24, 2010

TM

@anywhere

Saturday, July 24, 2010

TM

Core Features‣ Hovercards

‣ Tweet Box

‣ Follow Buttons

‣ Linkify

‣ Connect with Twitter

Saturday, July 24, 2010

TM

Easiest Example

<head> <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&amp;v=1"> </script> <script type="text/javascript"> twttr.anywhere(function(T) { T.hovercards(); T("#follow-placeholder").followButton('themattharris'); T("#tbox").tweetBox(); }); </script> </head>

Saturday, July 24, 2010

TM

Easiest Example

<head> <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&amp;v=1"> </script> <script type="text/javascript"> twttr.anywhere(function(T) { T.hovercards(); T("#follow-placeholder").followButton('themattharris'); T("#tbox").tweetBox(); }); </script> </head>

Saturday, July 24, 2010

TM

Easiest Example

<head> <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&amp;v=1"> </script> <script type="text/javascript"> twttr.anywhere(function(T) { T.hovercards(); T("#follow-placeholder").followButton('themattharris'); T("#tbox").tweetBox(); }); </script> </head>

Saturday, July 24, 2010

TM

Easiest Example

<head> <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&amp;v=1"> </script> <script type="text/javascript"> twttr.anywhere(function(T) { T.hovercards(); T("#follow-placeholder").followButton('themattharris'); T("#tbox").tweetBox(); }); </script> </head>

Saturday, July 24, 2010

TM

Easiest Example

<head> <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&amp;v=1"> </script> <script type="text/javascript"> twttr.anywhere(function(T) { T.hovercards(); T("#follow-placeholder").followButton('themattharris'); T("#tbox").tweetBox(); }); </script> </head>

Saturday, July 24, 2010

TM

More Info... Check outbit.ly/anywhere-begin

Saturday, July 24, 2010

TM

Bridge Code@anywhere to api.twitter.com

Saturday, July 24, 2010

TM

Overview

‣ Use connect with Twitter

‣ Hook into authComplete

‣ Send the bridge code to your server

‣ Exchange the bridge code using /oauth/access_token

‣ Verify

Saturday, July 24, 2010

TM

Use connect with Twitter

T("#connect-placeholder").connectButton({ authComplete: function(user, bridge_code) { $.post('/mypage.php', { 'bridge_code' : bridge_code }); }});

Saturday, July 24, 2010

TM

Hook into authComplete

T("#connect-placeholder").connectButton({ authComplete: function(user, bridge_code) { $.post('/mypage.php', { 'bridge_code' : bridge_code }); }});

Saturday, July 24, 2010

TM

Hook into authComplete

T("#connect-placeholder").connectButton({ authComplete: function(user, bridge_code) { $.post('/mypage.php', { 'bridge_code' : bridge_code }); }});

Saturday, July 24, 2010

TM

Send to your server

T("#connect-placeholder").connectButton({ authComplete: function(user, bridge_code) { $.post('/mypage.php', { 'bridge_code' : bridge_code }); }});

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

Exchange the token - PHP

$http->request( 'POST', 'https://api.twitter.com/oauth/access_token', array( 'oauth_bridge_code' => $_REQUEST['bridge_code'] ));

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

Streaming APINear-Realtime Access to Public Statuses

Saturday, July 24, 2010

TM

Streaming API‣ A persistent connection to Twitter servers

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

‣ Server to server integrations

Saturday, July 24, 2010

TM

Basic Usage‣ Curl with Basic Auth or Twurl with OAuth

‣ One connection per username permitted

http://stream.twitter.com/1/statuses/sample.json

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

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

Saturday, July 24, 2010

TM

Streaming API - Default Level‣ 200 x Keywords

‣ 400 x Follow userids

‣ 10 x 1-degree location boxes

Saturday, July 24, 2010

TM

More Info... Check outbit.ly/streaming_api

Saturday, July 24, 2010

TM

Stay Informed... Joinbit.ly/twitter-anywhere-talkbit.ly/twitter-dev-talk

Important Stuff@twitterapistatus.twitter.combit.ly/twitter-api-announce

Saturday, July 24, 2010

TM

Help... Check outdev.twitter.com

Saturday, July 24, 2010

TM

Questions? Follow us attwitter.com/twitterapitwitter.com/themattharris

Saturday, July 24, 2010

TM

Saturday, July 24, 2010