1.0 -> 1.0.1
============
-+ command line client example
+ changing profile and background images
+ full coverage of current code in tests
+ prepare for social graph changes mentioned on mailinglist
+ finish search api
+ autodetect authenticated user's ID [DONE]
-+ retweet api
++ timeline paging
Future...
=========
+ database-based cache ?
+ rate limit governor
++ command line client example
++ retweet api [DONE BUT NEEDS TESTING]
require_auth = True
)
- # TODO: add support for changing profile and background images
+ """Update profile image"""
+ def update_profile_image(self, filename):
+ bind_api(
+ path = '/account/update_profile_image.json',
+ method = 'POST',
+ parser = parse_user,
+ require_auth = True
+ )(self, post_data = _pack_image(filename, 700))
+
+ """Update profile background image"""
+ def update_profile_image(self, filename, *args, **kargs):
+ bind_api(
+ path = '/account/update_profile_background_image.json',
+ method = 'POST',
+ parser = parse_user,
+ allowed_param = ['tile']
+ require_auth = True
+ )(self, post_data = _pack_image(filename, 800))
"""Update profile"""
update_profile = bind_api(
parser = parse_trend_results
)(self)
+def _pack_image(filename, max_size):
+ """Pack image from file into multipart-formdata post body"""
+ # image must be less than 700kb in size
+ try:
+ if os.path.getsize(filename) > (max_size * 1024):
+ raise TweepError('File is too big, must be less than 700kb.')
+ except os.error, e:
+ raise TweepError('Unable to access file')
+
+ # image must be gif, jpeg, or png
+ file_type = mimetypes.guess_type(filename)
+ if file_type is None:
+ raise TweepError('Could not determine file type')
+ if file_type is not 'image/gif' and file_type is not 'image/jpeg'
+ and file_type is not 'image/png':
+ raise TweepError('Invalid file type for image')
+
+ # build the mulitpart-formdata body
+ fp = open(filename, 'rb')
+ BOUNDARY = '--Tw3ePy'
+ body = []
+ body.append('--' + BOUNDARY)
+ body.append('Content-Disposition: form-data; name="image"; filename="%s"' % filename)
+ body.append('Content-Type: %s' % file_type)
+ body.append('')
+ body.append(fp.read())
+ body.append('--' + BOUNDARY + '--')
+ body.append('')
+ fp.close()
+
+ return '\r\n'.join(body)
+