dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.93k stars 1.14k forks source link

Feed API problem #127

Closed botsbuzz closed 7 years ago

botsbuzz commented 7 years ago

The Feed API example return me tons of "undefined". Here the code:

var _ = require('underscore');
var Promise = require('bluebird');

var accountId = '2922464285'
var feed = new Client.Feed.UserMedia(session, accountId);

Promise.mapSeries(_.range(0, 20), function() {
    return feed.get();
})
.then(function(results) {
    // result should be Media[][]
    var media = _.flatten(results);
    var urls = _.map(media, function(medium) {
        return _.last(medium.images)
    });
    console.log(urls);
})
anjaneyulu-nyros commented 7 years ago

Try Like this

.then(function(results) { var media = _.flatten(results); console.log(media) }

botsbuzz commented 7 years ago

Perfect! Thank you!

anjaneyulu-nyros commented 7 years ago

Are you getting total result of page or partial data of page

botsbuzz commented 7 years ago

Partial data.

I'm looking to understand the feed SelfLiked. Do you know the meaning?

huttarichard commented 7 years ago

@botsbuzz posts liked by you ;)

botsbuzz commented 7 years ago

@huttarichard Thank you for the reply. It was what I was hoping. but it gives me the wrong results (posts to which I never put a like)

botsbuzz commented 7 years ago

@huttarichard This is my code:

    Client.Session.create(device, storage, myUsername, myPassword)
        .then(function(session) {
            // Now you have a session, we can follow / unfollow, anything...
            // And we want to follow Instagram official profile
            return [session, Client.Account.searchForUser(session, username)]   
        })
        .spread(function(session, account) {
            session = session;
            console.log(account.id);
            //return Client.Relationship.create(session, account.id);

            var feed = new Client.Feed.SelfLiked(session, account.id);

            Promise.mapSeries(_.range(0, 20), function() {
                return feed.get();
            })
            .then(function(results) { var media = _.flatten(results); console.log(media) });

        }) //spread
anjaneyulu-nyros commented 7 years ago

Try like this

`var accountId = 'yourid' var feed = new Client.Feed.SelfLiked(session,accountId); get_total_data(); function get_totaldata() { Promise.map(.range(0, 1), function() { return feed.get(); }) .then(function(results) {

console.log(results)

if(feed.isMoreAvailable() == true) { var next_cursor=feed.getCursor() console.log('next_cursor :'+next_cursor); feed.setCursor(next_cursor); get_total_data(); } }) }`

botsbuzz commented 7 years ago

@anjaneyulu-nyros great! thank you! It works but return posts to which I never put a like. this is just a problem of mine?