Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter instagram api results by tag AND username

I'd like to create an application that pulls images from a certain tag, but only from a certain username. For example: I'd like #skullcandysnow images to appear, but only the ones from the 'skullcandy' account name.

Here is how I'm pulling the tag:

 $(function() {

 $.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/tags/skullcandysnow/media/recent?client_id=d1685ded02da4c5eb2b08632f1256119&access_token=fce470c159274e2b9482976f93fd3435",
        success: function(data) {



            for (var i = 0; i < 10; i++) {

        $(".SC-IG").append("<img class='SC-instagram-image' src='" + data.data[i].images.low_resolution.url +"' /><div class='counts'><img src='images/skullcandyad_04.jpg'><h3 class='ig-likescount'>" + data.data[i].likes.count +"</h3><h3 class='ig-commentscount'>" + data.data[i].comments.count +"</h3></div> ");   


        }
       }

    });
});

You can view what I'm working on here: http://yobeat.com/zz_testing/yobeatinstagramwidget_v3.html

Thanks!

like image 666
user1940181 Avatar asked Dec 31 '12 19:12

user1940181


1 Answers

Looking through the code provided by the user on his 'figured it out' website, the solution was as follow:

imgLimit = 1000;
// Grab all TAGS of choice
$.ajax({
    type: "GET",
    dataType: "jsonp",
    cache: false,
    url: "https://api.instagram.com/v1/tags/TAG_OF_CHOICE/media/recent?client_id=CLIENT_ID&access_token=ACCESS_TOKEN",
    success: function(data) { 
    // Loop through the data and only add the images that match a certain user ID
        for (var i = 0; i < imgLimit; i++) {
            var usertag = data.data[i].user.id;
            if (usertag === "USER_ID_OF_CHOICE") {
                // Add image to page
                addImage(data.data[i]);
            }
       }
    }
});
like image 188
TeckniX Avatar answered Nov 14 '22 23:11

TeckniX