Skip to content

Instantly share code, notes, and snippets.

@kusor
Created November 30, 2009 11:08
Show Gist options
  • Save kusor/245396 to your computer and use it in GitHub Desktop.
Save kusor/245396 to your computer and use it in GitHub Desktop.
>> require 'rubygems'
=> true
>> require 'patron'
=> true
>> require 'json'
=> true
>> s = Patron::Session.new
=> #<Patron::Session:0x187a978>
>> s.base_url = 'http://twitter.com'
=> "http://twitter.com"
>> response = s.get('/statuses/show/6197732378.json')
=> #<Patron::Response @status_line='HTTP/1.1 200 OK'>
>> response.body
=> "{\"in_reply_to_user_id\":null,\"in_reply_to_status_id\":null,\"truncated\":false,\"source\":\"web\",\"favorited\":false,\"geo\":null,\"user\":{\"profile_sidebar_fill_color\":\"e0ff92\",\"description\":\"web junkie, free software libertarian, open media believer\",\"screen_name\":\"furilo\",\"friends_count\":941,\"following\":null,\"statuses_count\":5188,\"time_zone\":\"Madrid\",\"profile_sidebar_border_color\":\"87bc44\",\"notifications\":null,\"favourites_count\":106,\"geo_enabled\":false,\"profile_text_color\":\"000000\",\"url\":\"http://www.furilo.com\",\"profile_background_image_url\":\"http://a1.twimg.com/profile_background_images/1176842/pattern_097.gif\",\"verified\":false,\"profile_link_color\":\"0000ff\",\"protected\":false,\"profile_background_tile\":true,\"created_at\":\"Sun Nov 19 22:38:11 +0000 2006\",\"location\":\"Madrid, Spain\",\"name\":\"\\u00c1lvaro Ortiz\",\"profile_background_color\":\"9ae4e8\",\"profile_image_url\":\"http://a1.twimg.com/profile_images/305246290/Foto_2_normal.jpg\",\"id\":13139,\"utc_offset\":3600,\"followers_count\":2228},\"in_reply_to_screen_name\":null,\"created_at\":\"Mon Nov 30 10:15:33 +0000 2009\",\"id\":6197732378,\"text\":\"\\u221a\\u00a0esto funciona en windows y linux?\"}"
>> out = JSON.parse(response.body)
=> {"user"=>{"name"=>"Álvaro Ortiz", "profile_sidebar_fill_color"=>"e0ff92", "profile_background_tile"=>true, "profile_link_color"=>"0000ff", "profile_sidebar_border_color"=>"87bc44", "url"=>"http://www.furilo.com", "favourites_count"=>106, "id"=>13139, "description"=>"web junkie, free software libertarian, open media believer", "utc_offset"=>3600, "protected"=>false, "profile_text_color"=>"000000", "profile_background_color"=>"9ae4e8", "verified"=>false, "geo_enabled"=>false, "notifications"=>nil, "time_zone"=>"Madrid", "screen_name"=>"furilo", "followers_count"=>2228, "profile_background_image_url"=>"http://a1.twimg.com/profile_background_images/1176842/pattern_097.gif", "statuses_count"=>5188, "friends_count"=>941, "profile_image_url"=>"http://a1.twimg.com/profile_images/305246290/Foto_2_normal.jpg", "location"=>"Madrid, Spain", "created_at"=>"Sun Nov 19 22:38:11 +0000 2006", "following"=>nil}, "favorited"=>false, "truncated"=>false, "text"=>"√ esto funciona en windows y linux?", "id"=>6197732378, "geo"=>nil, "in_reply_to_status_id"=>nil, "in_reply_to_user_id"=>nil, "in_reply_to_screen_name"=>nil, "source"=>"web", "created_at"=>"Mon Nov 30 10:15:33 +0000 2009"}
>> out['text']
=> "√ esto funciona en windows y linux?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment