2

I am trying to make a bot which makes a post and then self replies. The only issue I am having is that response.id is not fetching the tweet id. Could I get any pointers as to the right way to fetch the id of a tweet that was just posted?

# Post Tweet
response = client.create_tweet(text=tweet_msg)

# Respond to first tweet posted
client.create_tweet(text=reply_msg, in_reply_to_tweet_id=response.id)

1 Answer 1

2

Was actually wondering how to do this myself and just figured it out. When you create a tweet and print it you should notice a response in your terminal. It should look something like this.

Response(data={'edit_history_tweet_ids': ['ID_IS_HERE'], 'id': 'ID_IS_HERE', 'text': 'TWEET_TEXT_IS_HERE'.

To access the id you'll have to say have to say the following

# Post Tweet
response = client.create_tweet(text=tweet_msg)

# Respond to first tweet posted
client.create_tweet(text=reply_msg, in_reply_to_tweet_id=response.data['id'])

You're accessing the ID of the tweet with the response.data['id'] part, hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.