diff --git a/lib/twitter/client.rb b/lib/twitter/client.rb index 43c566359..8d03fea9e 100644 --- a/lib/twitter/client.rb +++ b/lib/twitter/client.rb @@ -40,13 +40,13 @@ module Twitter # @note All methods have been separated into modules and follow the same grouping used in {http://dev.twitter.com/doc the Twitter API Documentation}. # @see http://dev.twitter.com/pages/every_developer class Client - include Twitter::Authenticatable include Twitter::Connection include Twitter::Request - attr_accessor *Config::VALID_OPTIONS_KEYS + MAX_USERS_PER_REQUEST = 100 + # Initializes a new API object # # @param attrs [Hash] @@ -2402,11 +2402,11 @@ def update_with_media(status, image, options={}) # Twitter.users(7505382, 14100886) # Same as above def users(*args) options = args.last.is_a?(Hash) ? args.pop : {} - users = args - options.merge_users!(Array(users)) - get("/1/users/lookup.json", options).map do |user| - Twitter::User.new(user) - end + args.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users| + get("/1/users/lookup.json", options.merge_users(Array(users))).map do |user| + Twitter::User.new(user) + end + end.flatten end # Access the profile image in various sizes for the user with the indicated screen name diff --git a/lib/twitter/core_ext/hash.rb b/lib/twitter/core_ext/hash.rb index 18ef87697..e0fa714bb 100644 --- a/lib/twitter/core_ext/hash.rb +++ b/lib/twitter/core_ext/hash.rb @@ -92,6 +92,14 @@ def merge_user!(user, prefix=nil, suffix=nil) self end + # Take a multiple users and merge them into the hash with the correct keys + # + # @param users [Array, Set] An array of Twitter user IDs, screen_names, or objects. + # @return [Hash] + def merge_users(*users) + self.dup.merge_users!(users) + end + # Take a multiple users and merge them into the hash with the correct keys # # @param users [Array, Set] An array of Twitter user IDs, screen_names, or objects.