Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination #10

Open
dseeker opened this issue Mar 28, 2015 · 2 comments
Open

Pagination #10

dseeker opened this issue Mar 28, 2015 · 2 comments

Comments

@dseeker
Copy link

dseeker commented Mar 28, 2015

Is there a way to use pagination?

I'm trying to get all users who liked an item of media, is it just undocumented or not possible?

@theirnameissam
Copy link

This could help you out: https://github.com/stevenschobert/instafeed.js

@VojtaSim
Copy link

You can use instagram's native method to paginate by passing options object before callback function.

Example:

function loadUserMedia()  {
    API.user.self.media({ count: 13 }, function (response) {
        parseMedia(response);
    });
}

function parseMedia (response) {
    if (response.meta.code !== 200) 
        error(response);

    if (response.data.length == 0) 
        return;

    var lastMediaID, loadMoreBtn = $(/**  **/);

    for (var i = 0, media; media = response.data[i]; i++) {
        lastMedia = media.id;
        if (media.type == "video") continue;  // remove if you want videos

        // do your own stuff
        images.add(/** **/);
    }

    if (response.pagination && response.pagination.next_max_id !== undefined) {
        loadMoreBtn.removeClass('hidden');

        loadMoreBtn.off('click').on('click.instagram.user.loadMore', function (e) {
            e.preventDefault();

            $(this).addClass('loading');

            API.user.self.media({ count: 13, max_id: lastMedia }, function (response) {
                parseMedia(response);
            });
        });
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants