7

I'm creating a Twitter bot to share information about Covid-19 cases where I live, but I'm trying to organize all the information in a single thread

By "thread" I mean a "Twitter Thread": many tweets created together to make it readable and concise

I'm using Tweepy in Python, but I can't find a way to do that. I can post a single tweet (by using api.update_status), but I can't create a full thread by adding new tweets the the first one.

That's my first StackOverflow question, so I hope it's good enough to be understandable

Thank you

Hallsand
  • 71
  • 1
  • 2
  • I don't think there's a concept of threads on twitter, except for "replies" to your own first message. To post a reply, take a look at this thread: https://stackoverflow.com/questions/9322465/reply-to-tweet-with-tweepy-python – Rayan Ral Jun 10 '20 at 04:20

1 Answers1

9

I recommend you to have a look at https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update . In Tweepy when you call update_status, it will return a Status object, so it should be a case of doing something like the following logic:

original_tweet = api.update_status(status=question_text)

reply1_tweet = api.update_status(status=reply1_text, 
                                 in_reply_to_status_id=original_tweet.id, 
                                 auto_populate_reply_metadata=True)

reply2_tweet = api.update_status(status=reply2_text, 
                                 in_reply_to_status_id=reply1_tweet.id, 
                                 auto_populate_reply_metadata=True)

The original_tweet variable will hold the reference to the first tweet and as you call 'api.update_status' (named reply1_tweet) for the second time, you need to have as a parameter the id of the post immediately above this one on the thread logic (which in this case is the original_tweet).

The explanation above refers to this specific part in_reply_to_status_id=original_tweet.id.

Well, I don't know if the explanation is clear enough, I hope it helped...

PC_paulo
  • 91
  • 1
  • 2