Exemple #1
0
 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)
Exemple #2
0
    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)
Exemple #3
0
 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
Exemple #4
0
    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)
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
    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)
Exemple #8
0
 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_)
Exemple #9
0
 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))
Exemple #10
0
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)
Exemple #12
0
 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_)
Exemple #13
0
 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)
Exemple #14
0
 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))
Exemple #15
0
 def lookup_users(self, user_ids=None, screen_names=None):
     return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names))
Exemple #16
0
 def lookup_users(self, user_ids=None, screen_names=None):
     return self._lookup_users(list_to_csv(user_ids), list_to_csv(screen_names))
Exemple #17
0
 def lookup_statuses(self, ids=None):
     return self._lookup_statuses(list_to_csv(ids))