Skip to content
Browse files

add all_follower_ids and all_following_ids methods

  • Loading branch information...
1 parent 6649694 commit d892f42e8c9ead2878905057d14da615a2665973 @maxjustus committed Oct 27, 2011
Showing with 27 additions and 3 deletions.
  1. BIN lib/twitter_oauth/.user.rb.swp
  2. +27 −3 lib/twitter_oauth/user.rb
View
BIN lib/twitter_oauth/.user.rb.swp
Binary file not shown.
View
30 lib/twitter_oauth/user.rb
@@ -29,19 +29,31 @@ def all_friends(username = false)
end
users
end
+
+ # Returns all pages of friends
+ def all_friend_ids(username = false)
+ ids = []
+ cursor = "-1"
+ while cursor != 0 do
+ json = get("/friends/ids.json?cursor=#{cursor}#{username ? "&screen_name=#{username}" : ''}")
+ cursor = json["next_cursor"]
+ ids += json["ids"]
+ end
+ ids
+ end
# Returns the 100 last followers
def followers(page=1)
return get("/statuses/followers.json?page=#{page}") if page == 1
- users = []
+ ids = []
cursor = "-1"
page.times do
return [] if cursor == 0
json = get("/statuses/followers.json?cursor=#{cursor}")
cursor = json["next_cursor"]
- users = json["users"]
+ ids = json["ids"]
end
- users
+ ids
end
# Returns all pages of followers
@@ -56,5 +68,17 @@ def all_followers(username = false)
users
end
+ # Returns all pages of friends
+ def all_follower_ids(username = false)
+ ids = []
+ cursor = "-1"
+ while cursor != 0 do
+ json = get("/followers/ids.json?cursor=#{cursor}#{username ? "&screen_name=#{username}" : ''}")
+ cursor = json["next_cursor"]
+ ids += json["ids"]
+ end
+ ids
+ end
+
end
end

0 comments on commit d892f42

Please sign in to comment.
Something went wrong with that request. Please try again.