【问题标题】:Using twython to reply to a given tweet使用 twython 回复给定的推文
【发布时间】:2017-12-06 05:49:53
【问题描述】:

如何使用 twython 回复任何 twitter id?

这个很棒的 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')

只是想知道,如何使用 twython 回复推文?

【问题讨论】:

    标签: python twitter twython


    【解决方案1】:

    假设你有 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')
    

    这可以在here找到。

    此外,您应该查看 twython 包中的 endpoints.py 以了解更多使用 Twython 的功能。

    【讨论】:

    • 这还不够。您必须以您要回复的用户的屏幕名称开始回复消息。
    • 以上是对的,但现在还有设置auto_populate_reply_metadata=True的选项,它会自动将回复状态的用户附加到回复用户列表中(因为Twitter现在支持隐式回复列表用户)。
    猜你喜欢
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    相关资源
    最近更新 更多