Commit 08009fb7 authored by Joshua Roesslein's avatar Joshua Roesslein
Browse files

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
parent 482ca5e4
......@@ -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())
......
......@@ -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])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment