Search code examples
pythontwittertweepy

How to Retweet the latest Tweet of a certain account?


I need to be able to Retweet the latest Tweet from a certain Twitter account, but have an issue getting the Tweet ID of the latest post automatically. For example, I have used the api.retweet() function, but I need to know what to enter into this function, as well as how to pull the ID from the latest Tweet. This is using the Tweepy module (Python Twitter Module).


Solution

  • You can use API.user_timeline to retrieve their latest Tweet and the id attribute of that Status/Tweet object representing their most recent Tweet.