def remove_list_members(self, screen_name=None, user_id=None, slug=None, list_id=None, owner_id=None, owner_screen_name=None): """ Perform bulk remove of list members from user ID or screenname """ return self._remove_list_members(list_to_csv(screen_name), list_to_csv(user_id), slug, list_id, owner_id, owner_screen_name)
def lookup_users(self, user_ids=None, screen_names=None, include_entities=None): """ Perform bulk look up of users from user ID or screenname """ 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)
def _lookup_users(self, user_ids=[], screen_names=[]): '''A wrapper around __uncached_lookup_users to store the returned Users in the cache''' try: users = self.__uncached_lookup_users(list_to_csv(user_ids), list_to_csv(screen_names)) self.cache.store_users(*users) return users except TweepError, e: # We looked for a user that does not exist if 'page does not exist' in e.reason: return [] raise
def lookup_users(self, user_ids=None, screen_names=None, include_entities=None): """ Perform bulk look up of users from user ID or screenname """ 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)
def update_status(self, *args, **kwargs): """ :reference: https://dev.twitter.com/rest/reference/post/statuses/update :allowed_param:'status', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'lat', 'long', 'source', 'place_id', 'display_coordinates', 'media_ids' """ post_data = {} media_ids = kwargs.pop("media_ids", None) if media_ids is not None: post_data["media_ids"] = list_to_csv(media_ids) return bind_api( api=self, path="/statuses/update.json", method="POST", payload_type="status", allowed_param=[ "status", "in_reply_to_status_id", "in_reply_to_status_id_str", "lat", "long", "source", "place_id", "display_coordinates", ], require_auth=True, )(post_data=post_data, *args, **kwargs)
def remove_list_members(self, screen_names=[], user_ids=[], owner_screen_name=None, owner_id=None, slug=None, list_id=None): if not isinstance(screen_names, list) or not isinstance(user_ids, list): raise TweepError('screen_names and user_ids must be list object') # Note: # Twitter API document says "up to 100 are allowed in a single request." # But request with 100 user IDs or screen names are always failed for over capacity. # So their limit is set to 50. if len(screen_names) > 50 or len(user_ids) > 50: raise TweepError('Length of screen_names or user_ids must be up to 50') return self._remove_list_members( list_to_csv(screen_names), list_to_csv(user_ids), owner_screen_name = owner_screen_name, owner_id = owner_id, slug = slug, list_id = list_id)
def update_status(self, media_ids=None, *args, **kwargs): """ :reference: https://dev.twitter.com/rest/reference/post/statuses/update :allowed_param:'status', 'in_reply_to_status_id', 'lat', 'long', 'source', 'place_id', 'display_coordinates', 'media_ids' """ post_data = {} if media_ids is not None: post_data["media_ids"] = list_to_csv(media_ids) return bind_api( api=self, path='/statuses/update.json', method='POST', payload_type='status', allowed_param=['status', 'in_reply_to_status_id', 'lat', 'long', 'source', 'place_id', 'display_coordinates'], require_auth=True )(post_data=post_data, *args, **kwargs)
def statuses_lookup(self, id_, include_entities=None, trim_user=None, map_=None): return self._statuses_lookup(list_to_csv(id_), include_entities, trim_user, map_)
def lookup_friendships(self, user_ids=None, screen_names=None): """ Perform bulk look up of friendships from user ID or screenname """ return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names))
def lookup_statuses(self, status_ids=None): return self._lookup_statuses(list_to_csv(status_ids))
def remove_list_members(self, screen_name=None, user_id=None, slug=None, list_id=None, owner_id=None, owner_screen_name=None): return self._remove_list_members(list_to_csv(screen_name), list_to_csv(user_id), slug, list_id, owner_id, owner_screen_name)
def lookup_users(self, user_ids=None, screen_names=None, include_entities=True): return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names), include_entities)
def lookup_users(self, user_ids=None, screen_names=None): return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names))
def lookup_statuses(self, ids=None): return self._lookup_statuses(list_to_csv(ids))