问题描述
链接示例:
- https://imgur.com/ouo812r (1.图像链接)
- https://imgur.com/obef9yi (2.图像链接) )
- https://imgur.com/wrfbk (相册链接)
目前,我只是在所有链接上都在做https://api.imgur.com/3/gallery/[ID].json,并且获得is_album是正确的.这适用于1.图像链接和上面的专辑链接,但它返回404的2.图像链接(不知道为什么).
如果返回404,我正在为失败的图像做一个图像API请求(https://api.imgur.com/3/image/OBEF9yi.json).
我想知道是否有一种更轻松的(使用API调用)来确定哪种链接是哪种内容类型(专辑或图像).
推荐答案
我实际上在IMGUR API中找到了一个错误.不可能为URL获得这样的简短URL.向Imgur报告,他们已经认识到.
一旦修复了它,就可以进行图像API调用(https://api.imgur.com/3/image/[ID].json)并获得Wheter animated是正确的.
据我所知,其他推荐答案
没有办法使用一个API调用.基于 api 有两个API呼叫图像和专辑,/3/3/GALLERY/COLLAM {id}和/3/gallery/image/{id}.
我认为imgur建议您使用搜索库等诸如搜索库等的API方法之一,以获取画廊项目的列表,并且根据" is_album"是否为true,请查询上述API之一.
.问题描述
Link examples:
- https://imgur.com/oUO812R (1. image link)
- https://imgur.com/OBEF9yi (2. image link)
- https://imgur.com/WRFBK (album link)
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.
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).
推荐答案
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.
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.
其他推荐答案
There isn't a way to do it with one API call as far as I know. Based on the API there are two API calls for images and albums, /3/gallery/album/{id} and /3/gallery/image/{id}.
I think Imgur recommends you use one of the API methods like search gallery etc to get a list of gallery items, and depending on if "is_album" is true or not then query one of the above APIs.