Reply to Tweet with Tweepy - Python

mcriecken picture mcriecken · Feb 17, 2012 · Viewed 19.1k times · Source

I can't seem to get tweepy to work with replying to a specific tweet:

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)

### at this point I've grabbed the tweet and loaded it to JSON...

tweetId = tweet['results'][0]['id']

api.update_status('My status update',tweetId)

The api says it takes optional parameters and in_reply_to_status_id is the first, but it seems to be ignoring it altogether. This script will post an updated status, but it does not link it as a reply to the tweetId that I'm passing.

API for reference: http://code.google.com/p/tweepy/wiki/APIReference#update_status

Anyone have any ideas? I feel like I'm missing something simple here...

Thanks in advance.

Answer

Ibrahim Alghamdi picture Ibrahim Alghamdi · May 21, 2012

I ran into the same problem, but luckily I found the solution. You just need to include the user's screen_name in the tweet:

api.update_status('@<username> My status update', tweetId)