ruby on rails - Fetching all user's pictures with the Instagram gem -


i'd fetch pictures using instagram gem (https://github.com/instagram/instagram-ruby-gem) i'm not able find out how.

this i'm trying far:

client = instagram.client(access_token: token) client.user_recent_media.each |media|     puts media.images.thumbnail.url end 

it apparently works (those instagram images) i'm not able fetch all of them or select in way content want instagram.

for example see method user_recent_media accepts "count" attribute should let me use sort of pagination:

(from https://github.com/instagram/instagram-ruby-gem/blob/master/lib/instagram/client/users.rb#l150) @option options [integer] :count (nil) limits number of results returned per page 

unfortunately don't how paginations supposed work. if example request 1000 media elements (just of them) doesn't work , returns way less elements, @ point i'm stuck because have no idea how requeste page 2

has used instagram gem this? appreciated

below functioning code old app imports users (i ran 1.1.5 instagram gem , still works), uses cursor. should able change few variables , lines , on way:

  def import_followers     response = user.client.user_follows     followers = [].concat(response)     next_cursor = response.pagination[:next_cursor]     while !(next_cursor.to_s.empty?)       response = instagram.user_follows(uid, {:cursor => next_cursor})       next_cursor = response.pagination[:next_cursor]       followers.concat(response)     end     return followers   end 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -