我似乎无法回复特定的推文:
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)
api说它需要可选参数而in_reply_to_status_id是第一个,但它似乎完全忽略了它。此脚本将发布更新状态,但它不会将其链接为对我传递的tweetId的回复。
API供参考:http://code.google.com/p/tweepy/wiki/APIReference#update_status
有人有什么想法吗?我觉得我在这里缺少一些简单的东西......
提前致谢。
答案 0 :(得分:16)
我遇到了同样的问题,但幸运的是我找到了解决方案。您只需要在推文中包含用户的screen_name:
api.update_status('@<username> My status update', tweetId)
答案 1 :(得分:13)
您也可以
api.update_status("my update", in_reply_to_status_id = tweetid)
答案 2 :(得分:11)
那么,这很简单。我必须指定推文使用@符号的方式。
api.update_status('My status update @whoIReplyTo',tweetId)
答案 3 :(得分:1)
我发现在指定我回复的推文时我必须包含推文的ID字符串(而不是实际的ID号)
api.update_status('@whoIReplyTo my reply tweet',tweetIdString)
答案 4 :(得分:1)
只需发布解决方案,就不会让其他人像我那样受苦。
Twitter更新了API,并添加了名为auto_populate_reply_metadata
所有您需要做的就是将其设置为true,其余的都应保留。这是一个示例:
api.update_status(status = 'your reply', in_reply_to_status_id = tweetid , auto_populate_reply_metadata=True)
此外,status_id是tweet URL末尾的一长串数字。祝你好运!
答案 5 :(得分:0)
这似乎是Tweepy中的一个错误 - 即使您使用正确的参数设置调用 api.update_status ,
api.update_status(status=your_status, in_reply_to_status=tweet_to_reply_to.id)
推文不会是回复。要获得回复,您需要提及要回复的用户 AND 指定正确的in_reply_to_status ID。
reply_status = "@%s %s" % (username_to_reply_to, your_status)
api.update_status(status=reply_status, in_reply_to_status=tweet_to_reply_to.id)
请记住 - Tweepy和Twitter的服务器仍然强制执行最多140个字符,因此请务必检查
len(reply_status) <= 140
同样,我认为这是一个错误,因为在Twitter应用程序中,您可以在不嵌入您回复的人的用户名的情况下进行回复。