From 9e09163782820dd9e9a1d06f1eefdf2667a85142 Mon Sep 17 00:00:00 2001 From: chebee7i Date: Mon, 29 Sep 2014 23:48:10 -0500 Subject: [PATCH] Use POST for users/lookup. The reference documentation recommends POST rather than GET for larger requests of user lookups. Also, added an option for 'include_entities'. --- tweepy/api.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 45fdd1e..e2e0b96 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -275,20 +275,29 @@ class API(object): allowed_param=['id', 'url', 'maxwidth', 'hide_media', 'omit_script', 'align', 'related', 'lang'] ) - def lookup_users(self, user_ids=None, screen_names=None): + def lookup_users(self, user_ids=None, screen_names=None, include_entities=None): """ Perform bulk look up of users from user ID or screenname """ - return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names)) + post_data = {} + if include_entities is not None: + include_entities = 'true' if include_entities else 'false' + post_data['include_entities'] = include_entities + if user_ids: + post_data['user_id'] = list_to_csv(user_ids) + if screen_names: + post_data['screen_name'] = list_to_csv(screen_names) + + return self._lookup_users(post_data=post_data) @property def _lookup_users(self): """ :reference: https://dev.twitter.com/rest/reference/get/users/lookup - allowed_param='user_id', 'screen_name' + allowed_param='user_id', 'screen_name', 'include_entities' """ return bind_api( api=self, path='/users/lookup.json', payload_type='user', payload_list=True, - allowed_param=['user_id', 'screen_name'], + method='POST', ) def me(self): -- 2.25.1