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

查看:57
本文介绍了从 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 中发现了一个错误.应该不可能为 URL 获得这样的短 URL.报告给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天全站免登陆