通过排除已知用户的主题标签显示instagram图片

时间:2013-10-15 09:42:11

标签: jquery cordova feed instagram

我正在开发一个phonegap应用。我正在使用下一个使用jQuery的HTML代码来显示带有#beavercreek标签的Instagram图片

<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>

此外,这是instagramfeed.js档案的代码

$(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;
        }
    }
});
});

我希望结果显示带有此主题标签(beavercreek)的Instagram图片,但不包括已知用户名的图片。有人可以帮助我吗?。

非常感谢。

1 个答案:

答案 0 :(得分:0)

如果您可以接收相同的响应但只是在代码中过滤它,那么您可能可以

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;
    } 
}