Twitter images with :large not showing up in API console
我遇到了一个奇怪的问题,即使用户发布了一条带有推文的图片,某些图像也不会在API控制台中显示。
请注意,此时间轴中的第二条推文(无论如何现在)始于...新#play'男人和女人之间的世界首演...
https://twitter.com/BatterseaBarge
在某些情况下,图像会被发布,并在图像URL后面附加:large。即
1 | <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提要的用户来说,加载时间也可能会稍有放慢。缓存永远是最好的肯定!
1 2 3 4 5 6 7 8 9 10 11 | $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, ) ); |
啊!您已经遇到了新样式的Tweets。根据Twitter的文档,新推文不计算正文中的媒体URL。
为了防止新的推文破坏旧客户端,您需要在代码中包括一些选项。
此刻,您正在呼叫
Tweets的新样式要求您添加选项
例如,调用
会让你回来:
"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",
因此,添加