Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit d932162

Browse files
committed
Merge pull request #88 from cmlh/user_follows
Feature - User Follows
2 parents 190bd95 + 7f607ef commit d932162

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

sample_app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def get_nav():
4040
"<li><a href='/media_search'>Media Search</a> Calls media_search - Get a list of media close to a given latitude and longitude</li>"
4141
"<li><a href='/media_popular'>Popular Media</a> Calls media_popular - Get a list of the overall most popular media items</li>"
4242
"<li><a href='/user_search'>User Search</a> Calls user_search - Search for users on instagram, by name or username</li>"
43+
"<li><a href='/user_follows'>User Follows</a> Get the followers of @instagram uses pagination</li>"
4344
"<li><a href='/location_search'>Location Search</a> Calls location_search - Search for a location by lat/lng</li>"
4445
"<li><a href='/tag_search'>Tags</a> Search for tags, view tag info and get media by tag</li>"
4546
"</ul>")
@@ -190,6 +191,28 @@ def user_search(session):
190191
print e
191192
return "%s %s <br/>Remaining API Calls = %s/%s" % (get_nav(),content,api.x_ratelimit_remaining,api.x_ratelimit)
192193

194+
@route('/user_follows')
195+
def user_follows(session):
196+
access_token = session.get('access_token')
197+
content = "<h2>User Follows</h2>"
198+
if not access_token:
199+
return 'Missing Access Token'
200+
try:
201+
api = client.InstagramAPI(access_token=access_token)
202+
# 25025320 is http://instagram.com/instagram
203+
user_follows, next = api.user_follows('25025320')
204+
users = []
205+
for user in user_follows:
206+
users.append('<li><img src="%s">%s</li>' % (user.profile_picture,user.username))
207+
while next:
208+
user_follows, next = api.user_follows(with_next_url=next)
209+
for user in user_follows:
210+
users.append('<li><img src="%s">%s</li>' % (user.profile_picture,user.username))
211+
content += ''.join(users)
212+
except Exception, e:
213+
print e
214+
return "%s %s <br/>Remaining API Calls = %s/%s" % (get_nav(),content,api.x_ratelimit_remaining,api.x_ratelimit)
215+
193216
@route('/location_search')
194217
def location_search(session):
195218
access_token = session.get('access_token')

0 commit comments

Comments
 (0)