Instagram API: How to get all user media? -
in general need user media.
user has more 250 photos.
i /users/1/media/recent/?access_token=...&count=250
but returns 20 photos.
maybe instagram has limit getting media. if is, response has pagination solve it. there max id photo. how know first (min) id photo paginate then?
you're right, instagram api return 20 images per call. you'll have use pagination feature.
if you're trying use api console. you'll want first allow api console authenticate via instagram login. you'll want select oauth2 under authentication dropdown.
once authenticated, use left hand side menu select users/{user-id}/media/recent endpoint. sake of post {user-id} can replace self. use account retrieve information.
at bare minimum what's needed endpoint. once send, you'll json returned you. @ top of returned information after server info, you'll see pagination portion next_url , next_max_id.
next_max_id you'll use parameter query. remember max_id id of image oldest of 20 first returned. used return images earlier image.
you don't have use max_id if don't want to. can grab id of image you'd start querying more images from.
so returned data, copy max_id parameter max_id. request url should https://api.instagram.com/v1/users/self/media/recent?max_id=xxxxxxxxxxx xxxxxxxxxxx max_id. hit send again , should next 20 photos.
from there you'll receive updated max_id. can use again next set of 20 photos until going through of user's photos.
what i've done in project i'm working on load first 20 photos returned initial recent media request. then, assign images data-id (-id can whatever you'd be). added load more button on bottom of photo set.
when button clicked, use jquery grab last image , it's data-id attribute , use create call via ajax , append results end of photos on page. instead of button replace have infinite scrolling effect.
hope helps.
Comments
Post a Comment