Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added several unauthorized methods that twitter provides.

  • Loading branch information...
commit 55813617c5b4cf672800bf7f9e7473904e3c3194 1 parent f46cdf9
John Nunemaker jnunemaker authored
3  History
View
@@ -2,6 +2,9 @@
* 1 minor enhancement
* added ability to pass query parameters to user method
* httpauth can now accept :ssl option to use https instead of http
+ * Added Twitter.status method for no auth calls to fetch status
+ * Added Twitter.friend_ids method for no auth calls to fetch status
+ * Added Twitter.follower_ids method for no auth calls to fetch status
0.6.5 - April 15, 2009
* 1 bug fix
16 examples/unauthorized.rb
View
@@ -0,0 +1,16 @@
+require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
+require 'pp'
+
+puts 'User', '*'*50
+pp Twitter.user('jnunemaker')
+pp Twitter.user('snitch_test')
+
+puts 'Status', '*'*50
+pp Twitter.status(1533815199)
+
+puts 'Friend Ids', '*'*50
+pp Twitter.friend_ids('jnunemaker')
+
+puts 'Follower Ids', '*'*50
+pp Twitter.follower_ids('jnunemaker')
+
13 lib/twitter.rb
View
@@ -38,6 +38,19 @@ def self.user(id)
response = HTTParty.get("http://twitter.com/users/show/#{id}.json", :format => :json)
Mash.new(response)
end
+
+ def self.status(id)
+ response = HTTParty.get("http://twitter.com/statuses/show/#{id}.json", :format => :json)
+ Mash.new(response)
+ end
+
+ def self.friend_ids(id)
+ HTTParty.get("http://twitter.com/friends/ids/#{id}.json", :format => :json)
+ end
+
+ def self.follower_ids(id)
+ HTTParty.get("http://twitter.com/followers/ids/#{id}.json", :format => :json)
+ end
end
directory = File.dirname(__FILE__)
1  test/fixtures/status_show.json
View
@@ -0,0 +1 @@
+{"in_reply_to_screen_name":null,"user":{"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"friends_count":161,"profile_sidebar_border_color":"181A1E","following":false,"favourites_count":80,"notifications":false,"profile_background_color":"1A1B1F","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","statuses_count":4771,"protected":false,"profile_background_tile":false,"profile_text_color":"666666","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","profile_link_color":"2FC2EF","location":"Mishawaka, Indiana","screen_name":"jnunemaker","id":4243,"profile_sidebar_fill_color":"252429","followers_count":1252},"text":"Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!","truncated":false,"in_reply_to_status_id":null,"created_at":"Thu Apr 16 14:12:36 +0000 2009","in_reply_to_user_id":null,"id":1533815199,"favorited":false,"source":"<a href=\"http:\/\/twitter.rubyforge.org\">Twitter App<\/a>"}
19 test/twitter_test.rb
View
@@ -16,4 +16,23 @@ class TwitterTest < Test::Unit::TestCase
user.name.should == 'John Nunemaker'
user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
end
+
+ should "have status method for unauthenticated calls to get a status" do
+ stub_get('http://twitter.com:80/statuses/show/1533815199.json', 'status_show.json')
+ status = Twitter.status(1533815199)
+ status.id.should == 1533815199
+ status.text.should == 'Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!'
+ end
+
+ should "have friend_ids method" do
+ stub_get('http://twitter.com:80/friends/ids/jnunemaker.json', 'friend_ids.json')
+ ids = Twitter.friend_ids('jnunemaker')
+ ids.size.should == 161
+ end
+
+ should "have follower_ids method" do
+ stub_get('http://twitter.com:80/followers/ids/jnunemaker.json', 'follower_ids.json')
+ ids = Twitter.follower_ids('jnunemaker')
+ ids.size.should == 1252
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.