Yukon
Yukon

Reputation: 57

How do I obtain the latest tweet from someone with tweepy?

I'm trying to get the latest tweet from an account and then automatically tweeting that with my bot account and I used this, but it doesn't seem to work:

def user_tweet(twitter):
    statuses = api.GetUserTimeline(screen_name=twitter)
    return statuses[0].text

if __name__ == "__main__":
    latest_tweet = user_tweet(sys.argv[1])
    api.update_status(latest_tweet)
time.sleep(3)

Is there a "quicker" way to do this? And how do I solve this?

Upvotes: 0

Views: 1177

Answers (1)

Yukon
Yukon

Reputation: 57

def user_tweet(twitter):
    statuses = api.user_timeline(screen_name=twitter)
    return statuses[0].text

if __name__ == "__main__":
    latest_tweet = user_tweet(sys.argv[1])
    api.update_status(latest_tweet)
time.sleep(3)

This was the solution! :)

Upvotes: 1

Related Questions