Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

#tmeetup BirdHackers API 101


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

#tmeetup BirdHackers API 101

  1. 1.
  2. 2. About Me<br />My Name is Joel Strellner<br />I go by @jstrellner on Twitter<br />I’ve been developing things using the Twitter API’s since March, 2008.<br />Twitturly ( )<br />inView ( )<br />
  3. 3. What is an API?<br />An API is a way for any service to allow<br />any other service to programmatically<br />access and interact with that services data.<br />
  4. 4. What API’s does Twitter offer?<br />Twitter currently offers 3 API’s:<br />REST API<br />REST Search API (previously Summize)<br />Streaming API<br />Depreciated API’s<br />Data Mining Feed<br />XMPP Feed<br />
  5. 5. REST API<br />The REST API is the primary API.<br />Used for:<br />Authentication<br />OAuth<br />Basic Auth (depreciated, use OAuth)<br />Posting Tweets<br />Getting your timeline (Tweets from those you follow)<br />Getting your Mentions<br />
  6. 6. Search API<br />Supports all of the same advanced search options that you can do on<br />Get trending topics by day, week or current<br />Allows you to consume it in atom and json formats<br />Supports fuzzy geolocation filtering<br />Uses *different* user ID’s than the REST API<br />Will be eventually the same (V2 of the API’s)<br />
  7. 7. Streaming API<br />Methods for the Public Stream:<br />Firehose (Not available to most)<br />Gardenhose (large portion of Firehose)<br />Spritzer (small portion of the Firehose)<br />Following Specific Users/Terms<br />Birddog / Shadow / Follow<br />must start with @user or have “in_reply_to” for that user<br />Allows you to follow 200k, 50k or 200 users, respectively<br />Track<br />Allows you to get any tweet matching a keyword<br />Does not support phrases<br />
  8. 8. What’s being built?<br />Seesmic Desktop ( )<br />Uses the REST API<br />Uses the Search API<br />Twitalizer ( )<br />Uses the Search API (might use the REST API too)<br />inView ( )<br />Uses the streaming API<br />Your App?<br />
  9. 9. What’s Coming Next?<br />Geolocation data in each Tweet<br />Retweeting (formally)<br />
  10. 10. How do you actually talk to the API?<br />PHP (getting a users timeline):<br />&lt;?php<br /> $ch = curl_init();<br />curl_setopt ($ch, CURLOPT_URL, ‘’); <br />curl_setopt ($ch, CURLOPT_USERAGENT, &apos;Twitturly / v0.6&apos;); <br />curl_setopt ($ch, CURLOPT_HEADER, 0);<br />curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);<br />curl_setopt ($ch, CURLOPT_MAXREDIRS, 10);<br />curl_setopt ($ch, CURLOPT_FAILONERROR, 0);<br />curl_setopt ($ch, CURLOPT_NOSIGNAL, 1); <br />curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30); <br />curl_setopt ($ch, CURLOPT_TIMEOUT, 60); <br />curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); <br />curl_setopt ($ch, CURLOPT_USERPWD, $username . &apos;:&apos; . $password); <br />$result = curl_exec($ch);<br />curl_close ($ch);<br />?&gt;<br />$result now has your response.<br />
  11. 11. ( XML Response )<br />
  12. 12. How to send a tweet (Basic Auth)<br />PHP:<br />&lt;?php<br />$msg = ‘this is an example tweet.’;<br /> $curl_handle = curl_init();<br />curl_setopt($curl_handle, CURLOPT_URL, &quot;;);<br />curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 30);<br />curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);<br />curl_setopt($curl_handle, CURLOPT_POST, 1);<br />curl_setopt($curl_handle, CURLOPT_POSTFIELDS, &quot;status=&quot; . urlencode($msg));<br />curl_setopt($curl_handle, CURLOPT_USERPWD, &quot;$twitter_username:$twitter_password&quot;);<br /> $buffer = curl_exec($curl_handle);<br />curl_close($curl_handle);<br />?&gt;<br />$buffer now has your response.<br />
  13. 13. Q&A<br />Any questions, or comments?<br />Feel free to tweet your question using the #tmeetuphashtag.<br />
  14. 14. Resources<br />Twitter API Documentation<br /><br />Twitter Streaming API Documentation<br /><br />Ask any API Question<br /><br />