【问题标题】:Twython get Tweet using the IDTwython 使用 ID 获取推文
【发布时间】:2012-12-14 04:32:55
【问题描述】:

使用Twython,如何仅使用推文 ID_STR 获得一条推文?

我知道我可以这样称呼它 (TwitterDocuentation)

"https://api.twitter.com/1/statuses/show.json?id=112652479837110273"

但是当我尝试使用 request() 方法在 twython 中调用它时,我一直遇到返回码 400 错误。我试图做一些类似于调用 showStatus 端点的事情

 tweet = twitter.request(endpoint='showStatus')

但这似乎不允许我插入 ID_STR 参数(或者我只是做错了)

 tweet = twitter.request(endpoint='showStatus',
              params={id:'112652479837110273'})

如何仅使用推文 ID 和 Twython 做到这一点?

【问题讨论】:

  • 谢谢!我还没有机会测试。

标签: python django twitter get twython


【解决方案1】:

Twython 没有 showStatus 方法,应该是 (show_status)

status = twitter.show_status(id="112652479837110273")

参考:https://github.com/ryanmcgrath/twython/blob/master/tests/test_core.py 第 147 行

【讨论】:

    【解决方案2】:

    这是怎么做的:

    status = twitter.showStatus(id="112652479837110273")
    print status['text']
    

    结果:

    @twitter meets @seepicturely at #tcdisrupt cc.@boscomonkey @episod http://t.co/6J2EgYM

    【讨论】:

    • 你是说 id 需要一个字符串作为参数吗?我已发送此错误:异常:Twitter API 返回 400(错误请求),处理您的请求时发生错误。当然,对于类型 。这目前在 Twython 工作吗? (顺便说一句:在 Twython API 中是 show_status)
    【解决方案3】:

    如果你在 2014 年还在尝试这样做,现在的代码是:

    twitter.statuses.show(id="126415614616154112")
    

    如果这不起作用,请查看:https://dev.twitter.com/docs/api/1/get/statuses/show/%3Aid Twitter 不断更新他们的 API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-30
      • 1970-01-01
      相关资源
      最近更新 更多