From: Joshua Roesslein Date: Fri, 19 Mar 2010 03:38:57 +0000 (-0500) Subject: Implemented API.lookup_users() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=08009fb70a1d3c64c17ce3adc09bb79852cc90ad;p=tweepy.git Implemented API.lookup_users() This method allows you to perform a bulk lookup of users by using their IDs or screen names. For more info see http://apiwiki.twitter.com/Twitter-REST-API-Method:-users-lookup --- diff --git a/tweepy/api.py b/tweepy/api.py index 0d821b5..d6d3e70 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -8,6 +8,7 @@ import mimetypes from tweepy.binder import bind_api from tweepy.error import TweepError from tweepy.parsers import ModelParser +from tweepy.utils import list_to_csv class API(object): @@ -142,6 +143,17 @@ class API(object): allowed_param = ['id', 'user_id', 'screen_name'] ) + """ Perform bulk look up of users from user ID or screenname """ + def lookup_users(self, user_ids=None, screen_names=None): + return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names)) + + _lookup_users = bind_api( + path = '/users/lookup.json', + payload_type = 'user', payload_list = True, + allowed_param = ['user_id', 'screen_name'], + require_auth = True + ) + """ Get the authenticated user """ def me(self): return self.get_user(screen_name=self.auth.get_username()) diff --git a/tweepy/utils.py b/tweepy/utils.py index 404bd86..fbd090a 100644 --- a/tweepy/utils.py +++ b/tweepy/utils.py @@ -92,3 +92,7 @@ def import_simplejson(): return json +def list_to_csv(item_list): + if item_list: + return ','.join([str(i) for i in item_list]) +