twitter - 通过 REST API 在 Twitter 上获取状态并不总是返回媒体 URL

标签 twitter twitter-rest-api

我似乎无法在状态中获取嵌入的 URL,例如,在 id=780804331608109057 -

https://twitter.com/i/web/status/780804331608109057

当我通过 GET /statuses/:id 检索此内容时, 与 include_entities设置为 true,响应如下所示:
"text":"Here\u2019s WSJ \"An Underwhelming Trump-Clinton Debate\u201d trying to spin this as something other than a Clinton triumph\u2026 https:\/\/t.co\/dpkmphGI8k", "truncated":true, "entities": {"hashtags":[],"symbols":[],"user_mentions":[],"urls":
[{"url":"https:\/\/t.co\/dpkmphGI8k", "expanded_url":"https:\/\/twitter.com\/i\/web\/status\/780804331608109057", "display_url":"twitter.com\/i\/web\/status\/7\u2026","indices":[114,137]}]}, "source":"\u003ca href=\"https:\/\/about.twitter.com\/products\/tweetdeck\"rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e",....

在我的 Web 客户端上查看时,状态会显示指向 WSJ 的链接(通过 t.co 引用)我希望这些 URL 中的一个或两个显示在我的 API 响应中:

  • https://pbs.twimg.com/media/CtX5Sz8WIAAm4tq.jpg
  • 看起来像“t.co”后跟“/HJs4kbmTKz”的短 URL 会是什么(我必须将其分解,所以不会提示。)

  • 我在这里做错了什么?

    最佳答案

    工作人员对 TwitterCommunity website 的快速响应最令人欣慰的是:

    You need to use tweet_mode=extended for the new longer Tweet format.



    引用:https://twittercommunity.com/t/missing-media-property-in-entities/70388/4

    搜索此新参数会在 dev.twitter.com 上生成适当的文档 - 可能存在有关此模式的更多文档链接。最显着的变化似乎是 key text不再用于非兼容模式 - 这就是状态文本所在的位置,除非您打开兼容模式,否则您现在必须使用 key full_text
    https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

    关于twitter - 通过 REST API 在 Twitter 上获取状态并不总是返回媒体 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39730519/

    相关文章:

    ios - Twitter 反向身份验证凭据突然停止在 iOS 上运行

    python - Twitter 搜索 API 参数

    ios - iOS 中使用 Twitter API 的简单 GET 请求

    selenium - 使用 Selenium 抓取 Twitter 粉丝

    iphone - 适用于 iOS 和网站的 Twitter 应用程序

    angular - Ionic4/Angular在Twitter上发布一条推文

    ios - Twitter Search Api 查找单词 'apple' iOS Swift 的提及

    Twitter REST API : How to get all the users not following back?

    twitter - 查找推文被浏览的次数

    html - 两个带有 addthis 的推特关注按钮,一个额外的推特关注按钮