Skip to content

Commit

Permalink
Added Twitter.user method to get user's information without authentic…
Browse files Browse the repository at this point in the history
…ating
  • Loading branch information
jnunemaker committed Apr 14, 2009
1 parent 50727e0 commit cb46975
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions History
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions examples/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
require 'pp'

pp Twitter.user('jnunemaker')
pp Twitter.user('snitch_test')
5 changes: 5 additions & 0 deletions lib/twitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/user.json
Original file line number Diff line number Diff line change
@@ -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"}
7 changes: 7 additions & 0 deletions test/twitter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.