Skip to main content
 首页 » 编程设计

python之Twython 使用 ID 获取推文

2025年05月04日19Free-Thinker

使用 Twython ,如何仅使用推文 ID_STR 获取单个推文?

我知道我可以这样调用它 ( TwitterDocuentation )

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

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

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

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

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

我如何仅使用推文 ID 和 Twython 来执行此操作? ?

请您参考如下方法:

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

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

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