Instagram gem: how to get next page of results?

instagram, ruby-on-rails

Solution

Got it. I don't think the `pagination` hash that Instagram passes back is accessible, but you can pass in a `max_id` option when querying, to get the next set of older pictures.

@results = Instagram.user_recent_media(some_user_id, {access_token: token, count: 10, max_id: 197679035065553721})

By passing in `max_id` (the id of a photo), it will return all results older than that. So grab the id of the oldest photo from the first query, and pass it in to get the next page.

Note: when you get the results, the ids of pictures are in the form: `197679035065553721_someuserid`. You have to parse out the first bit before the underscore, and pass that in as `max_id`.

Problem

How do I get the next page of results using the Instagram gem? The documentation for the API itself says there is a `pagination` hash passed in with each result (see here: http://instagram.com/developer/endpoints/). How do I access that with the gem?

Original source