简体   繁体   English

使用twython回复给定的tweet

[英]Using twython to reply to a given tweet

How can I use twython to post a reply to any twitter id? 我如何使用twython发表对任何Twitter ID的回复?

The way to post a status update on twitter by this awesome twython library is as follows - 这个很棒的twython库在Twitter上发布状态更新的方法如下-

    try:
        a = twitter.update_status(status=message)
        return HttpResponse("1", content_type='text/plain')
    except TwythonError as e:
        return HttpResponse(e, content_type='text/plain')

Just wanted to know, how can I post a reply to a tweet using twython? 只想知道,我如何使用twython发表对推文的回复?

Assuming you have the twitter id, you can simply do add in_reply_to_status to the update_status function. 假设您具有twitter id,则只需将in_reply_to_status添加到update_status函数即可。

try:
    a = twitter.update_status(status=message, in_reply_to_status_id=twitter_id)
    return HttpResponse("1", content_type='text/plain')
except TwythonError as e:
    return HttpResponse(e, content_type="'text/plain')

This can be found here . 可以在这里找到。

Also, you should check out the endpoints.py in the twython package for more functions to use Twython. 另外,您应该在twython软件包中检出endpoints.py,以获取更多使用Twython的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM