question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get all directInbox messages - isMoreAvailable doesn't work #1001

See original GitHub issue

Can’t get more then 10 directInbox messages

Trying to get all messages from inbox. I know there are lots of issues about this but still doesn’t work

Tried this but isMoreAvailable() always false

I can get all messages only after setting ‘thread_message_limit’ to 1000 in DirectInboxFeed class from npm package directly

Pls check how can we get all directInbox messages

Code


const ig = new instagramPrivateApi.IgApiClient();
// You must generate device id's before login.
// Id's generated based on seed
// So if you pass the same value as first argument - the same id's are generated every time
ig.state.generateDevice(process.env.IG_USERNAME);
// Optionally you can setup proxy url
//ig.state.proxyUrl = process.env.IG_PROXY;
(async () => {

  // Execute all requests prior to authorization in the real Android application
  // Not required but recommended
  await ig.simulate.preLoginFlow();
  const loggedInUser = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
  // The same as preLoginFlow()
  // Optionally wrap it to process.nextTick so we dont need to wait ending of this bunch of requests
  process.nextTick(async () => await ig.simulate.postLoginFlow());
  // Create UserFeed instance to get loggedInUser's posts


let isMoreAvailable = false;

const dmFeed = ig.feed.directInbox();
const dmFeedItems = await dmFeed.items();
    isMoreAvailable = await dmFeed.isMoreAvailable();

    const dmFeed2 = ig.feed.directInbox();
const dmFeedItems2 = await dmFeed2.items();
    isMoreAvailable = await dmFeed2.isMoreAvailable();

})();



Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Nerixyzcommented, Dec 7, 2019

items in both dmFeedItems and dmFeedItems2 are the same

This happens, because you are using a brand new feed every time. You have to reuse the feed or how else could it know about its state. The function I provided in #969 will then work. I assume you want to get all items, so integrating the function will look like this:

(async () => {
  // init IgApiClient as ig
  const items = await getAllItemsFromFeed(ig.feed.directInbox());
})();
async function getAllItemsFromFeed(feed) {
    let items = [];
    do {
        items = items.concat(await feed.items());
    } while(feed.isMoreAvailable());
    return items;
}
0reactions
dyigitpolatcommented, Jan 1, 2021

items in both dmFeedItems and dmFeedItems2 are the same

This happens, because you are using a brand new feed every time. You have to reuse the feed or how else could it know about its state. The function I provided in #969 will then work. I assume you want to get all items, so integrating the function will look like this:

(async () => {
  // init IgApiClient as ig
  const items = await getAllItemsFromFeed(ig.feed.directInbox());
})();
async function getAllItemsFromFeed(feed) {
    let items = [];
    do {
        items = items.concat(await feed.items());
    } while(feed.isMoreAvailable());
    return items;
}

doesnt work for DMs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to better diagnose -1001 "The … | Apple Developer Forums
The app is trying to send multiple requests over the minutes things are not working, and they are all failing with the same...
Read more >
Top 8 Ways to Fix Instagram Direct Messages Not Working
Let's discuss every possible scenario and troubleshoot the issue for you. 1. Check Instagram Servers. One of the biggest culprits behind ...
Read more >
Direct Messaging - Instagram Help Center
View and reply to disappearing photos and videos you receive in Instagram Direct.
Read more >
How to Check Your Instagram Messages - Alphr
1. Launch the Instagram app and log in. 2. Select your account, if you have multiple. 3. Tap the mail icon in the...
Read more >
About Professional Features in Instagram Direct ... - Facebook
When you switch to a professional account, you'll have access to an inbox that allows you to organize messages and control notifications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found