Search code examples
jquerycordovafeedinstagram

Show instagram pics by hashtag exluding known user


I'm developing a phonegap app. I'm using the next HTML code using jQuery to show instagram pics with hashtag #beavercreek

<html>
<head>
<title>Instagram test</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<script src="instagramfeed.js"></script>
<div class="instagramfeed"></div>
</body>
</html>

Also, this is the code of the instagramfeed.js archive

$(function() {
$.ajax({
    type: "GET",
    dataType: "jsonp",
    cache: false,
    url: "https://api.instagram.com/v1/tags/beavercreek/media/recent/?access_token=ACCESS_TOKEN_NUMBER",
    success: function(data) {
        console.log(data);
        for (var i = 0; i < 15; i++) {
            var date = new Date(parseInt(data.data[i].created_time) * 1000);
                $(".instagramfeed").append("\
                    <img src='" + data.data[i].images.standard_resolution.url +"' />\
<div>"+date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear()+"</div>\
<div><strong>"+data.data[i].user.username+"</strong> "+data.data[i].caption.text+"</div><br /><br />\
                ");
            date = null;
        }
    }
});
});

I would like that results show instagram pics with this hashtag (beavercreek) but excluding the pics from a known username. Can anybody help me?.

Thank you very much.


Solution

  • If you're ok with receiving the same response but just filtering it in your code, you might be able to do

    for (var i = 0; i < 15; i++) {
        if(data.data[i].user.username != YOUR_USERNAME) {
            var date = new Date(parseInt(data.data[i].created_time) * 1000);
                $(".instagramfeed").append("\
                    <img src='" + data.data[i].images.standard_resolution.url +"' />\
    <div>"+date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear()+"</div>\
    <div><strong>"+data.data[i].user.username+"</strong> "+data.data[i].caption.text+"</div><br /><br />\
                ");
            date = null;
        } 
    }