【问题标题】:Getting statuses on Twitter via REST API doesn't always return media URLs通过 REST API 在 Twitter 上获取状态并不总是返回媒体 URL
【发布时间】:2017-02-05 10:20:55
【问题描述】:

我似乎无法在某个状态中获取嵌入的 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",....

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

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

我在这里做错了什么?

【问题讨论】:

    标签: twitter twitter-rest-api


    【解决方案1】:

    一位工作人员在TwitterCommunity website 上的快速响应令人非常欣慰:

    您需要将 tweet_mode=extended 用于新的更长的推文格式。

    参考:https://twittercommunity.com/t/missing-media-property-in-entities/70388/4

    在 dev.twitter.com 上搜索这个新参数会产生相应的文档 - 可能存在更多关于此模式的文档链接。最显着的变化似乎是text 不再在非兼容模式下使用 - 这是状态文本所在的位置,除非您打开兼容模式,否则您现在必须使用钥匙full_text

    https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-21
      • 2013-10-29
      • 1970-01-01
      • 2017-06-29
      相关资源
      最近更新 更多