Skip to content

Instantly share code, notes, and snippets.

@kusor
Created July 31, 2009 16:12
Show Gist options
  • Save kusor/159290 to your computer and use it in GitHub Desktop.
Save kusor/159290 to your computer and use it in GitHub Desktop.
$ irb
>> require 'rubygems'
=> true
>> require 'patron'
=> true
>> require 'json'
=> true
>> sess = Patron::Session.new
=> #<Patron::Session:0x682cd4>
>> sess.timeout = 30
=> 30
>> sess.headers['Accept'] = 'application/json'
=> "application/json"
>> sess.base_url = "http://twitter.com/statuses/show"
=> "http://twitter.com/statuses/show"
>> resp = sess.get("/2870323107.json")
=> #<Patron::Response @status_line='HTTP/1.1 200 OK'>
>> status = JSON.parse(resp.body)
=> {"user"=>{"name"=>"Joyent", "profile_sidebar_fill_color"=>"DDFFCC", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"BDDCAD", "favourites_count"=>396, "url"=>"http://www.joyent.com", "id"=>666523, "description"=>"Joyent provides public and private Cloud Computing infrastructure and services.", "profile_text_color"=>"333333", "protected"=>false, "utc_offset"=>-28800, "profile_background_color"=>"c0bfbf", "verified"=>false, "notifications"=>false, "time_zone"=>"Pacific Time (US & Canada)", "screen_name"=>"joyent", "profile_background_image_url"=>"http://s3.amazonaws.com/twitter_production/profile_background_images/3330218/accelerator-diagram-lg.png", "friends_count"=>2367, "statuses_count"=>651, "followers_count"=>2306, "profile_image_url"=>"http://s3.amazonaws.com/twitter_production/profile_images/63989783/logo-accelerator_normal.png", "location"=>"Everywhere", "following"=>true, "created_at"=>"Fri Jan 19 18:25:46 +0000 2007"}, "favorited"=>false, "truncated"=>false, "text"=>"RT @jsconf:Help mod up the James Duncan video so the whole world can learn the greatness of ServerJS http://bit.ly/a8uMy #js #bacon #jsconf", "id"=>2870323107, "in_reply_to_user_id"=>nil, "in_reply_to_status_id"=>nil, "source"=>"<a href=\"http://www.nambu.com\">Nambu</a>", "in_reply_to_screen_name"=>nil, "created_at"=>"Mon Jul 27 13:41:41 +0000 2009"}
>> status['text']
=> "RT @jsconf:Help mod up the James Duncan video so the whole world can learn the greatness of ServerJS http://bit.ly/a8uMy #js #bacon #jsconf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment