Nerixyz / instagram_mqtt

Realtime and Push Notification (FBNS) support for the instagram-private-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can i receive likes and comments on my post?

gornostay25 opened this issue · comments

How to receive comments and likes? Is its possible?
I think I need to use this code

await ig.realtime.graphQlSubscribe(GraphQLSubscriptions.getLiveRealtimeCommentsSubscription('<broadcast-id>'));

But I don't know what is "broadcast-id"

commented

This subscription is only for live broadcasts. You can't receive like-events on realtime but you can receive notifications about comments. These are the same notifications that the app receives. Look into FBNS for this.

@Nerixyz Thank you very much! Can I receive likes also with FBNS?

commented

Can I receive likes also with FBNS?

No, as I said you can't receive like events on instagram. Also note that FBNS will not always be immediate or that some notifications won't show at all.

@Nerixyz Ok, thanks. Also wanted to ask you how to save a login session
I try to use this code but every time login method create new session and I can see it in instagram settings menu
https://github.com/Nerixyz/instagram_mqtt/blob/master/examples/push.example.ts#L48-L61

async function saveState(ig: IgApiClientExt) {
    return writeFileAsync('state.json', await ig.exportState(), { encoding: 'utf8' });
}

async function readState(ig: IgApiClientExt) {
    if (!await existsAsync('state.json'))
        return;
    await ig.importState(await readFileAsync('state.json', {encoding: 'utf8'}));
}

async function loginToInstagram(ig: IgApiClientExt) {
    ig.request.end$.subscribe(() => saveState(ig));
    await ig.account.login(IG_USERNAME, IG_PASSWORD);
}
commented

every time login method create new session

That's because every time you run the script, you'll login again. Try to check that you're logged in (e.g. checking that ig.account.currentUser resolves to a fulfilled promise or just checking that the state file exists) before calling .login here.