从imgur API获取imgur内容类型的最简单方法 [英] Easiest way to get imgur content type from imgur API

查看:162
本文介绍了从imgur API获取imgur内容类型的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

链接示例:

  • https://imgur.com/oUO812R (1. image link)
  • https://imgur.com/OBEF9yi (2. image link)
  • https://imgur.com/WRFBK (album link)

当前,我只对所有链接执行https://api.imgur.com/3/gallery/[ID].json,并获得is_album是否正确.这适用于上面的1.图片链接和相册链接,但对于2.图片链接返回404(不知道为什么).
如果返回404,则我正在为该失败的图像执行图像api请求(https://api.imgur.com/3/image/OBEF9yi.json).

Currently I'm just doing https://api.imgur.com/3/gallery/[ID].json for all links and get wether is_album is true or not. This works for the 1. image link and the album link above, but it returns 404 for the 2. image link (no idea why).
If it's returns 404, i'm doing an image api request (https://api.imgur.com/3/image/OBEF9yi.json) for that failed image.

我想知道是否有一种更简便的方法(通过一个api调用)来确定哪个链接是哪种内容类型(相册或图片).

I want to know if there's a easier (with one api call) way to determine which link is which content type (either album or image).

推荐答案

我实际上在imgur api中发现了一个错误.网址不可能像这样获得一个简短的网址.报告给imgur&他们已经认识到了.

I actually found a bug in the imgur api. It shouldn't be possible to get a short URL like this for URLs. Reported to imgur & they have recognized it.

一旦修复,就可以进行图像api调用(https://api.imgur.com/3/image/[ID].json),并弄清animated是否为真.

As soon as they've fixed it, it is possible to do an image api call (https://api.imgur.com/3/image/[ID].json) and get wheter animated is true or not.

这篇关于从imgur API获取imgur内容类型的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆