Twitter on Rails
                         Michael Bleigh, RailsConf 2009




Wednesday, May 6, 2009
Wednesday, May 6, 2009
Wednesday, May 6, 2009
What’s the big
                          f-ing deal?

Wednesday, May 6, 2009
MySpace


Wednesday, May 6, 2009
MySpace


Wednesday, May 6, 2009
Facebook


Wednesday, May 6, 2009
Facebook


Wednesday, May 6, 2009
How is
                           different?

Wednesday, May 6, 2009
Audience.
                                     Ben Garney via Flickr
Wednesday, May 6, 2009
Public.


                         three-B via Flickr
Wednesday, May 6, 2009
Search.


                               Vitó via Flickr
Wednesday, May 6, 2009
API.




                                benben via Flickr
Wednesday, May 6, 2009
In Code


Wednesday, May 6, 2009
Search API


Wednesday, May 6, 2009
require 'open-uri'
          require 'json'

          def search_twitter_for(query)
            query = CGI.escape(query)...
OAuth
Wednesday, May 6, 2009
TCM Hitchhiker via Flickr
Wednesday, May 6, 2009
There’s a gem
                           for that.

                                     ArtWerk via Flickr
Wednesday, May...
The OAuth Shuffle

           •      Consumer
           • Request Token
           • Authorization
           • Access!

...
Sign in with Twitter

           •      Consumer
           • Request Token
           • Authorize (Just Once)
           ...
gem install oauth --version 0.3.2




           require 'oauth'
           require 'json'

           # register your app...
Caveat OAuth

           •      The Advisory (no callbacks)
                 • Solution: One Dev App
           •      Rea...
Rails

Wednesday, May 6, 2009
TwitterAuth
                         github.com/mbleigh/twitter-auth




Wednesday, May 6, 2009
TwitterAuth makes
                     Rails Twitter apps
                       stupid simple.


Wednesday, May 6, 2009
Just enough magic.
                                              Steffe via Flickr
Wednesday, May 6, 2009
Livecoding!


Wednesday, May 6, 2009
Twisteners
                         Who actually listens?




Wednesday, May 6, 2009
Application Goals

           • Log in via Twitter
           • See a list of top mentioners
           • Tweet the top th...
Step 1:
                         Credentials

Wednesday, May 6, 2009
twitter.com/apps


Wednesday, May 6, 2009
Step 2:
                         Template

Wednesday, May 6, 2009
Type the Magic Words
                rails -m http://bit.ly/twitter-rails yourapp




Wednesday, May 6, 2009
TwitterAuth

                   • Engines-based login
                   • logged_in? and current_user
                   ...
Twitter Template


                   • helpers for common twitter needs
                   • instant gratification


Wedn...
Step 3:
                         Aggregate

Wednesday, May 6, 2009
Step 4:
                         Share

Wednesday, May 6, 2009
twisteners.heroku.com
                         github.com/mbleigh/twisteners




Wednesday, May 6, 2009
Follow me:

                         @mbleigh

Wednesday, May 6, 2009
Upcoming SlideShare
Loading in...5
×

Twitter on Rails

9,218

Published on

Learn how to build a Twitter application on Rails. Fast. Presented at RailsConf 2009 by Michael Bleigh.

Published in: Technology, Sports
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,218
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
115
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Twitter on Rails

  1. 1. Twitter on Rails Michael Bleigh, RailsConf 2009 Wednesday, May 6, 2009
  2. 2. Wednesday, May 6, 2009
  3. 3. Wednesday, May 6, 2009
  4. 4. What’s the big f-ing deal? Wednesday, May 6, 2009
  5. 5. MySpace Wednesday, May 6, 2009
  6. 6. MySpace Wednesday, May 6, 2009
  7. 7. Facebook Wednesday, May 6, 2009
  8. 8. Facebook Wednesday, May 6, 2009
  9. 9. How is different? Wednesday, May 6, 2009
  10. 10. Audience. Ben Garney via Flickr Wednesday, May 6, 2009
  11. 11. Public. three-B via Flickr Wednesday, May 6, 2009
  12. 12. Search. Vitó via Flickr Wednesday, May 6, 2009
  13. 13. API. benben via Flickr Wednesday, May 6, 2009
  14. 14. In Code Wednesday, May 6, 2009
  15. 15. Search API Wednesday, May 6, 2009
  16. 16. require 'open-uri' require 'json' def search_twitter_for(query) query = CGI.escape(query) JSON.parse( open(quot;http://search.twitter.com/search.json?q=#{query}quot;).read )['results'] end search_twitter_for('RailsConf').collect{|s| s['text']} [ quot;Packing up for #railsconf. Swine flu here we come!quot;, quot;Putting new strings on some guitars for the #RailsConf music jam”, quot;Vegas, baby! All the @contrast boys laying into their first drinks...”, ... ] Wednesday, May 6, 2009
  17. 17. OAuth Wednesday, May 6, 2009
  18. 18. TCM Hitchhiker via Flickr Wednesday, May 6, 2009
  19. 19. There’s a gem for that. ArtWerk via Flickr Wednesday, May 6, 2009
  20. 20. The OAuth Shuffle • Consumer • Request Token • Authorization • Access! Wednesday, May 6, 2009
  21. 21. Sign in with Twitter • Consumer • Request Token • Authorize (Just Once) • Access! Wednesday, May 6, 2009
  22. 22. gem install oauth --version 0.3.2 require 'oauth' require 'json' # register your application at http://twitter.com/apps consumer = OAuth::Consumer.new( 'mykey','mysecret', :site => 'http://twitter.com/' ) request_token = consumer.get_request_token puts request_token.authorize_url # go and visit the authorize URL access_token = request_token.get_access_token me = JSON.parse(access_token.get('/account/verify_credentials.json').body) me['screen_name'] # => 'mbleigh' Wednesday, May 6, 2009
  23. 23. Caveat OAuth • The Advisory (no callbacks) • Solution: One Dev App • Read/Write Inconsistency • Solution: Delete and Recreate Wednesday, May 6, 2009
  24. 24. Rails Wednesday, May 6, 2009
  25. 25. TwitterAuth github.com/mbleigh/twitter-auth Wednesday, May 6, 2009
  26. 26. TwitterAuth makes Rails Twitter apps stupid simple. Wednesday, May 6, 2009
  27. 27. Just enough magic. Steffe via Flickr Wednesday, May 6, 2009
  28. 28. Livecoding! Wednesday, May 6, 2009
  29. 29. Twisteners Who actually listens? Wednesday, May 6, 2009
  30. 30. Application Goals • Log in via Twitter • See a list of top mentioners • Tweet the top three “twisteners” Wednesday, May 6, 2009
  31. 31. Step 1: Credentials Wednesday, May 6, 2009
  32. 32. twitter.com/apps Wednesday, May 6, 2009
  33. 33. Step 2: Template Wednesday, May 6, 2009
  34. 34. Type the Magic Words rails -m http://bit.ly/twitter-rails yourapp Wednesday, May 6, 2009
  35. 35. TwitterAuth • Engines-based login • logged_in? and current_user • user.twitter.get(‘/api/path’) Wednesday, May 6, 2009
  36. 36. Twitter Template • helpers for common twitter needs • instant gratification Wednesday, May 6, 2009
  37. 37. Step 3: Aggregate Wednesday, May 6, 2009
  38. 38. Step 4: Share Wednesday, May 6, 2009
  39. 39. twisteners.heroku.com github.com/mbleigh/twisteners Wednesday, May 6, 2009
  40. 40. Follow me: @mbleigh Wednesday, May 6, 2009
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×