使用 javascript 使用 API 从画廊输出 imgur 图像 URL

Outputting imgur image URLs from a gallery using the API using javascript

我正在尝试编写一个从 imgur 相册中获取随机图像的脚本,但我无法检索图像 URL。

我正在使用 AJAX 获取相册的 JSON 数据,这是我目前拥有的数据:

$.ajax({
    type: "GET",
    url: "https://api.imgur.com/3/album/Cfy6A/images",
    dataType: "text",
    beforeSend: function(xhr) {
        xhr.setRequestHeader('Authorization', 'Client-ID <client-id>');
    },
    success: function(data) {
        var json = $.parseJSON(data);
        console.log(json);
    }
});

我能够获取 JSON 数据,我正在尝试为每个对象获取 'link',但我无法将其输出 just 作为数组的链接。

感谢任何帮助!

编辑:这是 JSON 响应的 pastebin:http://pastebin.com/JR068Dhf

您可以使用映射函数将所有链接放入数组中

var links = json.data.map(function(item) {
    return item.link;
})