问题
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).
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/35210559/easiest-way-to-get-imgur-content-type-from-imgur-api