Permalink
Browse files

Added Twitter.user method to get user's information without authentic…

…ating
  • Loading branch information...
1 parent 50727e0 commit cb46975eaa8aa7e02ad798ba8b7b62017f15604c @jnunemaker jnunemaker committed Apr 14, 2009
Showing with 22 additions and 0 deletions.
  1. +4 −0 History
  2. +5 −0 examples/user.rb
  3. +5 −0 lib/twitter.rb
  4. +1 −0 test/fixtures/user.json
  5. +7 −0 test/twitter_test.rb
View
@@ -1,3 +1,7 @@
+0.6.3 - April 14, 2009
+* 1 minor addition
+ * Added Twitter.user method to get user's information without authenticating
+
0.6.2 - April 14, 2009
* 1 minor addition
* added max to search so you can set the max id that should be used
View
@@ -0,0 +1,5 @@
+require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
+require 'pp'
+
+pp Twitter.user('jnunemaker')
+pp Twitter.user('snitch_test')
View
@@ -29,6 +29,11 @@ def self.firehose
response = HTTParty.get('http://twitter.com/statuses/public_timeline.json', :format => :json)
response.map { |tweet| Mash.new(tweet) }
end
+
+ def self.user(id)
+ response = HTTParty.get("http://twitter.com/users/show/#{id}.json", :format => :json)
+ Mash.new(response)
+ end
end
directory = File.dirname(__FILE__)
View
@@ -0,0 +1 @@
+{"profile_background_tile":false,"friends_count":159,"description":"Loves his wife, ruby, notre dame football and iu basketball","utc_offset":-18000,"notifications":null,"favourites_count":79,"profile_background_color":"1A1B1F","following":null,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","statuses_count":4752,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","time_zone":"Indiana (East)","protected":false,"screen_name":"jnunemaker","status":{"in_reply_to_status_id":null,"in_reply_to_user_id":null,"text":"224! http:\/\/flightcontrolled.com\/ Holy crap. There are some really high flight control scorers out there. *gives up* :D","favorited":false,"in_reply_to_screen_name":null,"created_at":"Tue Apr 14 20:38:49 +0000 2009","truncated":false,"id":1519558635,"source":"<a href=\"http:\/\/twitter.rubyforge.org\">Twitter App<\/a>"},"profile_link_color":"2FC2EF","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_fill_color":"252429","followers_count":1248,"location":"Mishawaka, Indiana","id":4243,"profile_sidebar_border_color":"181A1E"}
View
@@ -9,4 +9,11 @@ class TwitterTest < Test::Unit::TestCase
first.text.should == '#torrents Ultimativer Flirt Guide - In 10 Minuten jede Frau erobern: Ultimativer Flirt Guide - In 10 Mi.. http://tinyurl.com/d3okh4'
first.user.name.should == 'P2P Torrents'
end
+
+ should "have user method for unauthenticated calls to get a user's information" do
+ stub_get('http://twitter.com:80/users/show/jnunemaker.json', 'user.json')
+ user = Twitter.user('jnunemaker')
+ user.name.should == 'John Nunemaker'
+ user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
+ end
end

0 comments on commit cb46975

Please sign in to comment.