【问题标题】:Twitter images with :large not showing up in API console带有 :large 的 Twitter 图像未显示在 API 控制台中
【发布时间】:2017-02-02 22:47:21
【问题描述】:

我遇到了一个奇怪的问题,即即使用户通过推文发布了一些图像,API 控制台中也不会显示一些图像。

请注意此时间线中的第二条推文(无论如何现在),它以 ... 新 #play 'Between a Man and a Woman https://twitter.com/BatterseaBarge

在某些情况下,图像会被发布并在图像 url 上附加一个 :large。即。

<img src="https://pbs.twimg.com/media/exmaple.jpg:large"/>

现在,当这样的图像出现在帖子中并且我在 API 控制台上运行测试时,响应中不会出现 media_url。当然,当 :large 未附加到 url 时,它会出现在响应中。这是要测试的名称... BatterseaBarge https://dev.twitter.com/rest/tools/console

在我看来,这似乎是 API 中的一个错误。有人有什么想法吗?

后续回答:如下所述,这就是我的答案。我使用一个数组来获取 user_timeline 所以对于其他类似的人,希望它有所帮助。只是一个额外的说明,这确实显示了更多的东西,所以对于那些正在创建自己的 twitter 提要的人来说,加载时间可能也会减慢一点。缓存永远是最好的!

$fetchedTweets = $connection->get(
                'statuses/user_timeline',
                array(
                    'tweet_mode' => 'extended',
                    'screen_name' => $name,
                    'count' => $totalToFetch,
                    'exclude_replies' => $excludeReplies,
                    'images' => $description_image,
                    'include_rts' => $show_retweets,
                )
            );

【问题讨论】:

标签: twitter-bootstrap twitter sttwitterapi


【解决方案1】:

啊!您已经了解了风格的推文。根据Twitter's documentation,新推文不计算正文中的媒体 URL。

为了防止新推文破坏旧客户端,您需要在代码中包含一些选项。

目前,您正在调用 https://api.twitter.com/1.1/statuses/show/779978221479690240.json 并返回如下内容:

"text": "World premiere of new #play 'Between a Man and a Woman' TONIGHT, MON &amp; TUES @BatterseaBarge! Tkts… https://t .co/vZnDYowteX",

推文新样式需要你添加选项tweet_mode=extended

例如拨打https://api.twitter.com/1.1/statuses/show/779978221479690240.json?tweet_mode=extended

会让你回来的:

"full_text": "World premiere of new #play 'Between a Man and a Woman' TONIGHT, MON & TUES @BatterseaBarge! Tkts https://t .co/5yvfy4jwWX #moving #drama https://t .co/gs0gmC19PM", "media": [ { "id": 779977312918011900, "id_str": "779977312918011904", "indices": [ 141, 164 ], "media_url": "http://pbs.twimg.com/media/CtMJO81XgAAxDkn.jpg", "media_url_https": "https://pbs.twimg.com/media/CtMJO81XgAAxDkn.jpg",

所以,添加tweet_mode=extended 并使用"full_text" 属性,而不仅仅是text

【讨论】:

  • 你就是男人!现在这对我来说更加开放了,谢谢!
猜你喜欢
  • 1970-01-01
  • 2017-01-10
  • 1970-01-01
  • 2020-08-17
  • 2018-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多