Imrul.H
Imrul.H

Reputation: 5870

Get latest Instagram user photos using python-instagram library

I am using python-instagram api in my application in order to fetch recent photos from my instagram account. I am using following approach but couldn't succeed:

from instagram.client import InstagramAPI
api = InstagramAPI(client_id='MY_CLIENT_ID', client_secret='MY_CLIENT_SECRET')
recent_media= api.user_recent_media(my_user_id, 6, max_id)
for media in recent_media:
   print media.images['standard_resolution'].url
endfor

Here I don't understand what max_id parameter is. I have tried ignoring max_id, but it doesn't work. I have tried to get popula media, and it worked:

popular_media = api.media_popular(count=6)

Can anyone give me some idea? I am a PHP programmer and kinda new in python. All I need is - to get my recent instagram photos (6 of them) and show them in web page with an url so that user can click them. Do I need use access token for this? I hope not. Because I don't have any experience with python API yet.

Upvotes: 2

Views: 2816

Answers (1)

glmvrml
glmvrml

Reputation: 1632

  1. Try to authenticate your api first, this can be the case. You do not necessarily have access to user recent media otherwise
  2. Use named arguments in this case to be sure.

    api.user_recent_media(user_id=user_id, count=10)

  3. Max_id is optional and specifies, that you want to see photos with smaller id's. (e.g res=5,4,3,2,1 with max_id = 3 res=3,2,1)

Upvotes: 1

Related Questions