From: Vivien Meyet Date: Thu, 21 Nov 2013 11:00:52 +0000 (+0000) Subject: update-status-with-media add update with media feature X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3b57055f1f240e01de7734495a837e0c58158c7e;p=tweepy.git update-status-with-media add update with media feature --- diff --git a/tests/test_api.py b/tests/test_api.py index c21a11e..9a4c0d9 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -70,6 +70,10 @@ class TweepyAPITests(TweepyTestCase): deleted = self.api.destroy_status(id=update.id) self.assertEqual(deleted.id, update.id) + def testupdatestatuswithmedia(self): + update = self.api.update_with_media('examples/banner.png', status=tweet_text) + self.assertEqual(update.text, tweet_text) + def testgetuser(self): u = self.api.get_user('twitter') self.assertEqual(u.screen_name, 'twitter') diff --git a/tweepy/api.py b/tweepy/api.py index 5555bef..7ea5aa6 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -89,6 +89,22 @@ class API(object): require_auth = True ) + """ statuses/update_with_media """ + def update_with_media(self, filename, *args, **kwargs): + headers, post_data = API._pack_image(filename, 3072, form_field='media[]') + kwargs.update({'headers': headers, 'post_data': post_data}) + + return bind_api( + path='/statuses/update_with_media.json', + method = 'POST', + payload_type='status', + allowed_param = [ + 'status', 'possibly_sensitive', 'in_reply_to_status_id', 'lat', 'long', + 'place_id', 'display_coordinates' + ], + require_auth=True + )(self, *args, **kwargs) + """ statuses/destroy """ destroy_status = bind_api( path = '/statuses/destroy/{id}.json',