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

本文是小编为大家收集整理的关于从Imgur API获得Imgur内容类型的最简单方法的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

链接示例:

目前,我只是在所有链接上都在做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之一.

.

本文地址:https://www.itbaoku.cn/post/1937778.html

问题描述

Link examples:

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.