def exists_block(self, *args, **kargs): try: bind_api(path="/blocks/exists.json", allowed_param=["id", "user_id", "screen_name"], require_auth=True)( self, *args, **kargs ) except TweepError: return False return True
def update_profile_image(self, filename): headers, post_data = API._pack_image(filename, 700) bind_api( path = '/account/update_profile_image.json', method = 'POST', parser = parse_none, require_auth = True )(self, post_data=post_data, headers=headers)
def test(self): try: bind_api( path = '/help/test.json', )(self) except TweepError: return False return True
def update_profile_banner(self, filename, *args, **kargs): headers, post_data = API._pack_image(filename, 700, form_field="banner") bind_api( path = '/account/update_profile_banner.json', method = 'POST', allowed_param = ['width', 'height', 'offset_left', 'offset_right'], require_auth = True )(self, post_data=post_data, headers=headers)
def update_profile_background_image(self, filename, *args, **kargs): headers, post_data = API._pack_image(filename, 800) bind_api( path = '/account/update_profile_background_image.json', method = 'POST', payload_type = 'user', allowed_param = ['tile'], require_auth = True )(self, post_data=post_data, headers=headers)
def update_profile_background_image(self, filename, *args, **kargs): headers, post_data = API._pack_image(filename, 800) bind_api( path="/account/update_profile_background_image.json", method="POST", payload_type="user", allowed_param=["tile"], require_auth=True, )(self, post_data=post_data, headers=headers)
def exists_block(self, *args, **kargs): try: bind_api( path = '/blocks/exists.json', allowed_param = ['id', 'user_id', 'screen_name'], require_auth = True )(self, *args, **kargs) except TweepError: return False return True
def update_profile_banner(self, filename, **kargs): """ :reference: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner """ f = kargs.pop('file', None) headers, post_data = API._pack_image(filename, 700, form_field="banner", f=f) bind_api( api=self, path='/account/update_profile_banner.json', method='POST', allowed_param=['width', 'height', 'offset_left', 'offset_right'], require_auth=True )(self, post_data=post_data, headers=headers)
def update_profile_banner(self, filename, **kargs): """ :reference: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner """ f = kargs.pop("file", None) headers, post_data = API._pack_image(filename, 700, form_field="banner", f=f) bind_api( api=self, path="/account/update_profile_banner.json", method="POST", allowed_param=["width", "height", "offset_left", "offset_right"], require_auth=True, )(self, post_data=post_data, headers=headers)
def update_status_with_media(self, filename, *args, **kargs): headers, post_data = API._pack_media(filename, 3072) bind_api( path = '/statuses/update_with_media.json', method = 'POST', payload_type = 'status', allowed_param = ['status'], require_auth = True, secure = True )(self, post_data=post_data, headers=headers, status=kargs.get('status', ''))
def update_profile_background_image(self, filename, **kargs): """ :reference: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image """ f = kargs.pop("file", None) headers, post_data = API._pack_image(filename, 800, f=f) bind_api( api=self, path="/account/update_profile_background_image.json", method="POST", payload_type="user", allowed_param=["tile", "include_entities", "skip_status", "use"], require_auth=True, )(self, post_data=post_data, headers=headers)
def update_profile_background_image(self, filename, **kargs): """ :reference: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image """ f = kargs.pop('file', None) headers, post_data = API._pack_image(filename, 800, f=f) bind_api( api=self, path='/account/update_profile_background_image.json', method='POST', payload_type='user', allowed_param=['tile', 'include_entities', 'skip_status', 'use'], require_auth=True )(self, post_data=post_data, headers=headers)
def status_update_with_media(self, filename, *args, **kargs): """ " https://dev.twitter.com/docs/api/1/post/statuses/update_with_media """ headers, post_data = API._pack_media(filename, 3072) bind_api( path = '/statuses/update_with_media.json', method = 'POST', payload_type = 'status', allowed_param = ['status'], require_auth = True, upload_api = True, secure = True )(self, post_data=post_data, headers=headers, status=kargs.get('status', ''))
def destroy_list(self, slug): return bind_api( path="/%s/lists/%s.json" % (self.auth.get_username(), slug), method="DELETE", payload_type="list", require_auth=True, )(self)
def verify_credentials(self): try: return bind_api(path="/account/verify_credentials.json", payload_type="user", require_auth=True)(self) except TweepError as e: if e.response and e.response.status == 401: return False raise
def trends_current(self, *args, **kargs): return bind_api( host = 'search.' + self.host, path = '/trends/current.json', parser = parse_json, allowed_param = ['exclude'] )(self, *args, **kargs)
def search(self): """ :reference: https://dev.twitter.com/rest/reference/get/search/tweets :allowed_param:'q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'since', 'until', 'result_type', 'count', 'include_entities', 'from', 'to', 'source'] """ return bind_api( api=self, path="/search/tweets.json", payload_type="search_results", allowed_param=[ "q", "lang", "locale", "since_id", "geocode", "max_id", "since", "until", "result_type", "count", "include_entities", "from", "to", "source", ], )
def init(api, **kwargs): return bind_api( api=api, allowed_param=['command', 'media_type', 'total_bytes'], payload_type='json', **upload_kwargs )(command='INIT', **kwargs)['media_id_string']
def update_with_media(self, filename, *args, **kwargs): """ :reference: https://dev.twitter.com/rest/reference/post/statuses/update_with_media :allowed_param:'status', 'possibly_sensitive', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'lat', 'long', 'place_id', 'display_coordinates' """ f = kwargs.pop("file", None) headers, post_data = API._pack_image(filename, 3072, form_field="media[]", f=f) kwargs.update({"headers": headers, "post_data": post_data}) return bind_api( api=self, path="/statuses/update_with_media.json", method="POST", payload_type="status", allowed_param=[ "status", "possibly_sensitive", "in_reply_to_status_id", "in_reply_to_status_id_str", "lat", "long", "place_id", "display_coordinates", ], require_auth=True, )(*args, **kwargs)
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 trends_weekly(self, *args, **kargs): return bind_api( host = "search." + self.host, path = '/trends/weekly.json', parser = parse_json, allowed_param = ['date', 'exclude'] )(self, *args, **kargs)
def get_user(self): """ :reference: https://dev.twitter.com/rest/reference/get/users/show :allowed_param:'id', 'user_id', 'screen_name' """ return bind_api( api=self, path="/users/show.json", payload_type="user", allowed_param=["id", "user_id", "screen_name"] )
def search(self, *args, **kargs): return bind_api( host = 'search.' + self.host, path = '/search.json', parser = parse_search_results, allowed_param = ['q', 'lang', 'locale', 'rpp', 'page', 'since_id', 'geocode', 'show_user'], )(self, *args, **kargs)
def lists_subscriptions(self, *args, **kargs): return bind_api( path = '/%s/lists/subscriptions.json' % self.auth.get_username(), parser = parse_lists, allowed_param = ['cursor'], require_auth = True )(self, *args, **kargs)
def unsubscribe_list(self, owner, slug): return bind_api( path = '/%s/%s/subscribers.json' % (owner, slug), method = 'DELETE', parser = parse_list, require_auth = True )(self)
def destroy_list(self, slug): return bind_api( path = '/%s/lists/%s.json' % (self.auth.get_username(), slug), method = 'DELETE', payload_type = 'list', require_auth = True )(self)
def trends_available(self): """ :reference: https://dev.twitter.com/rest/reference/get/trends/available """ return bind_api( api=self, path='/trends/available.json', payload_type='json' )
def retweets(self, id, *args, **kargs): return bind_api( path = '/statuses/retweets/%s.json' % id, parser = parse_statuses, allowed_param = ['count'], require_auth = True )(self, *args, **kargs)
def upload(self, filename, status, lat=None, long=None, source=None): if source is None: source=self.source headers, post_data = API._pack_image(filename, 1024, source=source, status=status, lat=lat, long=long, contentname="pic") args = [status] allowed_param = ['status'] if lat is not None: args.append(lat) allowed_param.append('lat') if long is not None: args.append(long) allowed_param.append('long') if source is not None: args.append(source) allowed_param.append('source') return bind_api( path = '/statuses/upload.json', method = 'POST', payload_type = 'status', require_auth = True, allowed_param = allowed_param )(self, *args, post_data=post_data, headers=headers)
def is_subscribed_list(self, owner, slug, user_id): try: return bind_api( path = '/%s/%s/subscribers/%s.json' % (owner, slug, user_id), payload_type = 'user' )(self) except TweepError: return False
def create_friendship(self): """ :reference: https://dev.twitter.com/rest/reference/post/friendships/create :allowed_param:'id', 'user_id', 'screen_name', 'follow' """ return bind_api( api=self, path='/friendships/create.json', method='POST', payload_type='user', allowed_param=['id', 'user_id', 'screen_name', 'follow'], require_auth=True )
def user_timeline(self): """ :reference: https://dev.twitter.com/rest/reference/get/statuses/user_timeline :allowed_param:'id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'include_rts', 'trim_user', 'exclude_replies' """ return bind_api( api=self, path='/statuses/user_timeline.json', payload_type='status', payload_list=True, allowed_param=['id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'include_rts', 'trim_user', 'exclude_replies'] )
def verify_credentials(self, **kargs): try: return bind_api( path = '/account/verify_credentials.json', payload_type = 'user', require_auth = True, allowed_param = ['include_entities', 'skip_status'], )(self, **kargs) except TweepError, e: if e.response and e.response.status == 401: return False raise
def show_list_subscriber(self): """ :reference: https://dev.twitter.com/docs/api/1.1/get/lists/subscribers/show :allowed_param:'owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id """ return bind_api( api=self, path='/lists/subscribers/show.json', payload_type='user', allowed_param=['owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id'] )
def list_members(self): """ :reference: https://dev.twitter.com/docs/api/1.1/get/lists/members :allowed_param:'owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor """ return bind_api( api=self, path='/lists/members.json', payload_type='user', payload_list=True, allowed_param=['owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor'] )
def subscribe_list(self): """ :reference: https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/create :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id' """ return bind_api( api=self, path='/lists/subscribers/create.json', method='POST', payload_type='list', allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id'], require_auth=True)
def update_status(self): """ :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' """ 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 )
def create_saved_search(self): """ :reference: https://dev.twitter.com/rest/reference/post/saved_searches/create :allowed_param:'query' """ return bind_api( api=self, path='/saved_searches/create.json', method='POST', payload_type='saved_search', allowed_param=['query'], require_auth=True )
def destroy_saved_search(self): """ :reference: https://dev.twitter.com/rest/reference/post/saved_searches/destroy/%3Aid :allowed_param:'id' """ return bind_api( api=self, path='/saved_searches/destroy/{id}.json', method='POST', payload_type='saved_search', allowed_param=['id'], require_auth=True )
def destroy_block(self): """ :reference: https://dev.twitter.com/rest/reference/post/blocks/destroy :allowed_param:'id', 'user_id', 'screen_name' """ return bind_api( api=self, path='/blocks/destroy.json', method='POST', payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True )
def report_spam(self): """ :reference: https://dev.twitter.com/rest/reference/post/users/report_spam :allowed_param:'user_id', 'screen_name' """ return bind_api( api=self, path='/users/report_spam.json', method='POST', payload_type='user', allowed_param=['user_id', 'screen_name'], require_auth=True )
def destroy_favorite(self): """ :reference: https://dev.twitter.com/rest/reference/post/favorites/destroy :allowed_param:'id' """ return bind_api( api=self, path='/favorites/destroy.json', method='POST', payload_type='status', allowed_param=['id'], require_auth=True )
def update_profile(self): """ :reference: https://dev.twitter.com/rest/reference/post/account/update_profile :allowed_param:'name', 'url', 'location', 'description' """ return bind_api( api=self, path='/account/update_profile.json', method='POST', payload_type='user', allowed_param=['name', 'url', 'location', 'description'], require_auth=True )
def set_delivery_device(self): """ :reference: https://dev.twitter.com/rest/reference/post/account/update_delivery_device :allowed_param:'device' """ return bind_api( api=self, path='/account/update_delivery_device.json', method='POST', allowed_param=['device'], payload_type='user', require_auth=True )
def followers(self): """ :reference: https://dev.twitter.com/rest/reference/get/followers/list :allowed_param:'id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities' """ return bind_api(api=self, path='/followers/list.json', payload_type='user', payload_list=True, allowed_param=[ 'id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities' ])
def create_list(self): """ :reference: https://dev.twitter.com/rest/reference/post/lists/create :allowed_param:'name', 'mode', 'description' """ return bind_api( api=self, path='/lists/create.json', method='POST', payload_type='list', allowed_param=['name', 'mode', 'description'], require_auth=True )
def reverse_geocode(self): """ :reference: https://dev.twitter.com/rest/reference/get/geo/reverse_geocode :allowed_param:'lat', 'long', 'accuracy', 'granularity', 'max_results' """ return bind_api(api=self, path='/geo/reverse_geocode.json', payload_type='place', payload_list=True, allowed_param=[ 'lat', 'long', 'accuracy', 'granularity', 'max_results' ])
def destroy_list(self): """ :reference: https://dev.twitter.com/rest/reference/post/lists/destroy :allowed_param:'owner_screen_name', 'owner_id', 'list_id', 'slug' """ return bind_api( api=self, path='/lists/destroy.json', method='POST', payload_type='list', allowed_param=['owner_screen_name', 'owner_id', 'list_id', 'slug'], require_auth=True )
def sent_direct_messages(self): """ :reference: https://dev.twitter.com/rest/reference/get/direct_messages/sent :allowed_param:'since_id', 'max_id', 'count', 'page', 'tweet_mode' """ return bind_api(api=self, path='/direct_messages/sent.json', payload_type='direct_message', payload_list=True, allowed_param=[ 'since_id', 'max_id', 'count', 'page', 'tweet_mode' ], require_auth=True)
def favorites(self): """ :reference: https://dev.twitter.com/rest/reference/get/favorites/list :allowed_param:'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id' """ return bind_api(api=self, path='/favorites/list.json', payload_type='status', payload_list=True, allowed_param=[ 'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id' ])
def send_direct_message(self): """ :reference: https://dev.twitter.com/rest/reference/post/direct_messages/new :allowed_param:'user', 'screen_name', 'user_id', 'text' """ return bind_api( api=self, path='/direct_messages/new.json', method='POST', payload_type='direct_message', allowed_param=['user', 'screen_name', 'user_id', 'text'], require_auth=True )
def _statuses_lookup(self): """ :reference: https://dev.twitter.com/rest/reference/get/statuses/lookup :allowed_param:'id', 'include_entities', 'trim_user', 'map', 'tweet_mode' """ return bind_api( api=self, path='/statuses/lookup.json', payload_type='status', payload_list=True, allowed_param=['id', 'include_entities', 'trim_user', 'map', 'tweet_mode'], require_auth=True )
def retweet(self): """ :reference: https://dev.twitter.com/rest/reference/post/statuses/retweet/%3Aid :allowed_param:'id' """ return bind_api( api=self, path='/statuses/retweet/{id}.json', method='POST', payload_type='status', allowed_param=['id'], require_auth=True )
def search(self): """ :reference: https://dev.twitter.com/docs/api/1.1/get/search :allowed_param:'q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'since', 'until', 'result_type', 'count', 'include_entities', 'from', 'to', 'source'] """ return bind_api(api=self, path='/search/tweets.json', payload_type='search_results', allowed_param=[ 'q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'since', 'until', 'result_type', 'count', 'include_entities', 'from', 'to', 'source' ])
def lists_memberships(self): """ :reference: https://dev.twitter.com/rest/reference/get/lists/memberships :allowed_param:'screen_name', 'user_id', 'filter_to_owned_lists', 'cursor' """ return bind_api( api=self, path='/lists/memberships.json', payload_type='list', payload_list=True, allowed_param=['screen_name', 'user_id', 'filter_to_owned_lists', 'cursor'], require_auth=True )
def geo_search(self): """ :reference: https://dev.twitter.com/docs/api/1.1/get/geo/search :allowed_param:'lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within """ return bind_api(api=self, path='/geo/search.json', payload_type='place', payload_list=True, allowed_param=[ 'lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within' ])
def list_timeline(self): """ :reference: https://dev.twitter.com/docs/api/1.1/get/lists/statuses :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_rts """ return bind_api(api=self, path='/lists/statuses.json', payload_type='status', payload_list=True, allowed_param=[ 'owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_rts' ])
def update_profile_image(self, filename, file_=None): """ :reference: https://dev.twitter.com/rest/reference/post/account/update_profile_image :allowed_param:'include_entities', 'skip_status' """ headers, post_data = API._pack_image(filename, 700, f=file_) return bind_api( api=self, path='/account/update_profile_image.json', method='POST', payload_type='user', allowed_param=['include_entities', 'skip_status'], require_auth=True )(self, post_data=post_data, headers=headers)
def _remove_list_members(self): """ :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all :allowed_param:'screen_name', 'user_id', 'slug', 'lit_id', 'owner_id', 'owner_screen_name' """ return bind_api(api=self, path='/lists/members/destroy_all.json', method='POST', payload_type='list', allowed_param=[ 'screen_name', 'user_id', 'slug', 'lit_id', 'owner_id', 'owner_screen_name' ], require_auth=True)
def update_profile_colors(self): """ :reference: https://dev.twitter.com/rest/reference/post/account/update_profile_colors :allowed_param:'profile_background_color', 'profile_text_color', 'profile_link_color', 'profile_sidebar_fill_color', 'profile_sidebar_border_color' """ return bind_api( api=self, path='/account/update_profile_colors.json', method='POST', payload_type='user', allowed_param=['profile_background_color', 'profile_text_color', 'profile_link_color', 'profile_sidebar_fill_color', 'profile_sidebar_border_color'], require_auth=True )