From 7b593dfe41b147be35faf796cf352c1de1b058d4 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 12 Dec 2023 08:59:12 +0100 Subject: [PATCH] Attempt to update twitter media posting to api v2 Seems posting with images got broken in the update to api v2, let's see if the fix is this simple. --- postgresqleu/util/messaging/twitter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/postgresqleu/util/messaging/twitter.py b/postgresqleu/util/messaging/twitter.py index d31d78a5c..279b18524 100644 --- a/postgresqleu/util/messaging/twitter.py +++ b/postgresqleu/util/messaging/twitter.py @@ -248,7 +248,9 @@ def post(self, tweet, image=None, replytotweetid=None): }, timeout=30) if r.status_code != 200: return (None, 'Media upload: {}'.format(r.text)) - d['media_ids'] = r.json()['media_id'] + d['media'] = { + 'media_ids': r.json()['media_id'], + } while d['text']: r = self.tw.post('https://api.twitter.com/2/tweets', json=d, timeout=30)