如何使用 Instagram API 获取特定用户的帖子?

How to get posts of a specific user with Instagram API?

我想要特定用户的最新帖子,例如 Banksy。 我想出了以下内容,但它会给我一个错误:

GET https://api.instagram.com/v1/users/banksy/media/recent/?access_token={token}&callback=jQuery11110924438442569226_1445956181244&_=1445956181245

我的 ajax 电话是这样的:

$.ajax({
            type: "GET",
            dataType: "jsonp",
            cache: false,
            url: "https://api.instagram.com/v1/users/banksy/media/recent/?access_token={token}",
            success: function(response) {
                console.log('jfsdahuifhasudh')
                console.log(response);
                // placing the images on the page
                // for (var i = 0; i < 6; i++) {
                    
                    var html = '<a href="' + response.data[i].link + '" >'+
                    '<img src="' + response.data[i].images.low_resolution.url + '" alt="thumbnail" /></a>';
                    $(".instafeed").html(html);

                // }
            }, 

            error: function(data) {
                console.log('We have a problem!');
            }
        });

您在查询中使用了用户名; banksy 你的情况。 Resolve the username into ID 然后在您的查询中使用 id。例如;

https://api.instagram.com/v1/users/45951573/media/recent/?access_token={token}

*如果帐户是 public.

,API 将 return 发布

编辑

要获取带有特定主题标签的帖子,请使用:

https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token={token}

Further reading: Instagram API; Tags

更新

instaJS 是我以前写的 jQuery 插件。这个插件的独特之处在于它接受 username 而不是强迫用户解析他们的 id。完全免费使用 :),当然欢迎贡献 InstaJS on Github