Skip to content

Instantly share code, notes, and snippets.

@j0ni
Last active April 6, 2016 23:52
Show Gist options
  • Save j0ni/cad30763d156f82488dd37bfa345cae0 to your computer and use it in GitHub Desktop.
Save j0ni/cad30763d156f82488dd37bfa345cae0 to your computer and use it in GitHub Desktop.
<html>
<body>
<div id="app"></div>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script>
function startFader(maxId) {
var apiKey = 'a17b202a68d644619d0f4b7d0c4c498b';
return function () {
var url = "https://api.instagram.com/v1/tags/nofilter/media/recent?client_id="
+ apiKey + "&count=1"
+ (maxId != undefined ? "&MAX_ID=" + maxId : "");
var options = {
dataType: 'jsonp',
url: url
};
$.ajax(options).done(function (response) {
var newMaxId = response.data[0].id;
console.log(newMaxId);
response.data.forEach(function (photo) {
$('#app').append('<p><img src="' + photo.images.low_resolution.url + '"></p>');
});
setTimeout(startFader(newMaxId), 5000);
});
}
}
$(function () {
var start = startFader();
start();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment