簡體   English   中英

通過REST API在Twitter上獲取狀態並不總是返回媒體URL

[英]Getting statuses on Twitter via REST API doesn't always return media URLs

我似乎無法將嵌入的URL置於狀態,例如,在id = 780804331608109057中 -

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

當我通過GET /statuses/:id檢索這個,並將include_entities設置為true時,響應如下所示:

"text":"Here\’s WSJ \\"An Underwhelming Trump-Clinton Debate\” trying to spin this as something other than a Clinton triumph\… 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\…","indices":[114,137]}]}, "source":"\TweetDeck\<\\/a\>",....

在我的Web客戶端上查看時,狀態會顯示指向WSJ的鏈接(通過t.co引用)我希望在我的API響應中顯示這些URL中的一個或兩個:

  1. https://pbs.twimg.com/media/CtX5Sz8WIAAm4tq.jpg
  2. 什么是短的URL,看起來像“t.co”后面跟着“/ HJs4kbmTKz”(我必須打破這個,所以不要抱怨。)

我在這做錯了什么?

來自TwitterCommunity網站上的工作人員非常快速的回應是最令人滿意的:

您需要使用tweet_mode = extended來獲取新的更長的Tweet格式。

參考: 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM