dongyunque2511 2015-07-29 19:58
浏览 27
已采纳

是否可以检索附加到推文的gif?

I'm searching tweets through Twitter API with this endpoint

I'm testing with my own account. I tweeted a gif. But when I retrieve the json, I don't see the link of the attached media. It's automatically format in an url.

My aim is to store locally the images attached to tweets.

  • 写回答

1条回答 默认 最新

  • dongyu9667 2015-07-30 10:53
    关注

    Yes, it is possible. If you are looking for animated GIFs, you need to look in the extended_entities - here's an example:

    "extended_entities": { "media": [ { "id": 626705406224658400, "id_str": "626705406224658432", "indices": [ 29, 51 ], "media_url": "http://pbs.twimg.com/tweet_video_thumb/CLKBPxzWcAAFhYz.png", "media_url_https": "https://pbs.twimg.com/tweet_video_thumb/CLKBPxzWcAAFhYz.png", "url": "http://t.co/psSAzQfcFu", "display_url": "pic.twitter.com/psSAzQfcFu", "expanded_url": "http://twitter.com/edent/status/626705407550078976/photo/1", "type": "animated_gif",

    See! It tells you that there is an aGIF. Later on, you'll see the URL to directly download it.

    "sizes": { "small": { "w": 14, "h": 14, "resize": "fit" }, "medium": { "w": 14, "h": 14, "resize": "fit" }, "thumb": { "w": 14, "h": 14, "resize": "crop" }, "large": { "w": 14, "h": 14, "resize": "fit" } }, "video_info": { "aspect_ratio": [ 1, 1 ], "variants": [ { "bitrate": 0, "content_type": "video/mp4", "url": "https://pbs.twimg.com/tweet_video/CLKBPxzWcAAFhYz.mp4" } ] } } ] },

    Now, you can't download the GIF directly, but you can grab the video version of it.

    If you want other imgage (JPG, PNG, etc) take a look for the "media_url_https" field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题