1
I made a page to display Instagram photos that have some hashtag preselected by me. I used an example I found on the internet (I don’t remember the source) and I don’t know how to make pagination in the photos.
How can I make pagination with the Instagram API?
Script Example:
var userid = "12345678";
var accessToken = "12345678.5b9e1e6.37fbbfab2c594bb2b15c24161de6a744";
var tag = 'cute';
$.ajax({
type:"GET",
dataType:"jsonp",
cache:false,
url:"https://api.instagram.com/v1/tags/"+tag+"/media/recent?client_id="+userid+"&access_token="+accessToken+"&count=33&max_tag_id="+userid+"",
success:function(data) {
for (var i = 0; i < 100 ; i+=1){
$("#instagram").append("<figure class='miniatura_instagram img-rounded'><a href='" + data.data[i].link+"' target='_blank'><img alt='"+ data.data[i].user.full_name +"' src='" + data.data[i].images.low_resolution.url +"' ></a><figcaption class='cor'><a>@"+ data.data[i].user.full_name+" ⋆ ❤ "+data.data[i].likes.count+"</a></figcaption></figure>");
}
}
});
Thanks for the help @brasofilo. You know how I can go about pulling the next page until next_max_id comes empty?
– Odair
I’m afraid that some tags might have thousands of results... But I’ll put an example loop in the answer. Maybe the coolest was Infinite scroll.
– brasofilo
Thanks @brasofilo. I’m a beginner in javascript so I think the infinte scroll is for a next project
– Odair
Okay, I’ve updated the answer.
– brasofilo
Pro tip: as you saw, it is essential to consult the documentation of the Apis we work. I didn’t know the answer to this ;)
– brasofilo