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',
@property
def friends(self):
""" :reference: https://dev.twitter.com/rest/reference/get/friends/list
- :allowed_param:'id', 'user_id', 'screen_name', 'cursor'
+ :allowed_param:'id', 'user_id', 'screen_name', 'cursor', 'skip_status', 'include_user_entities'
"""
return bind_api(
api=self,
path='/friends/list.json',
payload_type='user', payload_list=True,
- allowed_param=['id', 'user_id', 'screen_name', 'cursor']
+ allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'skip_status', 'include_user_entities']
)
@property
'skip_status', 'include_user_entities']
)
+ @property
+ def get_settings(self):
+ """ :reference: https://dev.twitter.com/rest/reference/get/account/settings
+ """
+ return bind_api(
+ api=self,
+ path='/account/settings.json',
+ payload_type='json',
+ use_cache=False
+ )
+
+ @property
+ def set_settings(self):
+ """ :reference: https://dev.twitter.com/rest/reference/post/account/settings
+ :allowed_param:'sleep_time_enabled', 'start_sleep_time',
+ 'end_sleep_time', 'time_zone', 'trend_location_woeid',
+ 'allow_contributor_request', 'lang'
+ """
+ return bind_api(
+ api=self,
+ path='/account/settings.json',
+ method='POST',
+ payload_type='json',
+ allowed_param=['sleep_time_enabled', 'start_sleep_time',
+ 'end_sleep_time', 'time_zone',
+ 'trend_location_woeid', 'allow_contributor_request',
+ 'lang'],
+ use_cache=False
+ )
+
def verify_credentials(self, **kargs):
""" :reference: https://dev.twitter.com/rest/reference/get/account/verify_credentials
- :allowed_param:'include_entities', 'skip_status'
+ :allowed_param:'include_entities', 'skip_status', 'include_email'
"""
try:
return bind_api(
path='/account/verify_credentials.json',
payload_type='user',
require_auth=True,
- allowed_param=['include_entities', 'skip_status'],
+ allowed_param=['include_entities', 'skip_status', 'include_email'],
)(**kargs)
except TweepError as e:
if e.response and e.response.status == 401:
@property
def _add_list_members(self):
""" :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all
- :allowed_param:'screen_name', 'user_id', 'slug', 'lit_id',
+ :allowed_param:'screen_name', 'user_id', 'slug', 'list_id',
'owner_id', 'owner_screen_name'
"""
path='/lists/members/create_all.json',
method='POST',
payload_type='list',
- allowed_param=['screen_name', 'user_id', 'slug', 'lit_id',
+ allowed_param=['screen_name', 'user_id', 'slug', 'list_id',
'owner_id', 'owner_screen_name'],
require_auth=True
)
@property
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',
+ :allowed_param:'screen_name', 'user_id', 'slug', 'list_id',
'owner_id', 'owner_screen_name'
"""
path='/lists/members/destroy_all.json',
method='POST',
payload_type='list',
- allowed_param=['screen_name', 'user_id', 'slug', 'lit_id',
+ allowed_param=['screen_name', 'user_id', 'slug', 'list_id',
'owner_id', 'owner_screen_name'],
require_auth=True
)
def __init__(self, stream, chunk_size):
self._stream = stream
- self._buffer = u""
+ self._buffer = ''
self._chunk_size = chunk_size
def read_len(self, length):
if len(self._buffer) >= length:
return self._pop(length)
read_len = max(self._chunk_size, length - len(self._buffer))
- self._buffer += self._stream.read(read_len).decode("ascii")
+ self._buffer += self._stream.read(read_len)
def read_line(self, sep='\n'):
start = 0
return self._pop(loc + len(sep))
else:
start = len(self._buffer)
- self._buffer += self._stream.read(self._chunk_size).decode("ascii")
+ self._buffer += self._stream.read(self._chunk_size)
def _pop(self, length):
r = self._buffer[:length]
if exception:
# call a handler first so that the exception can be logged.
self.listener.on_exception(exception)
- raise
+ raise exception
def _data(self, data):
if self.listener.on_data(data) is False:
self._start(async)
def filter(self, follow=None, track=None, async=False, locations=None,
- stall_warnings=False, languages=None, encoding='utf8'):
+ stall_warnings=False, languages=None, encoding='utf8', filter_level=None):
self.body = {}
self.session.headers['Content-type'] = "application/x-www-form-urlencoded"
if self.running:
self.body['stall_warnings'] = stall_warnings
if languages:
self.body['language'] = u','.join(map(str, languages))
+ if filter_level:
+ self.body['filter_level'] = unicode(filter_level, encoding)
self.session.params = {'delimited': 'length'}
self.host = 'stream.twitter.com'
self._start(async)