Nerixyz / instagram_mqtt

Realtime and Push Notification (FBNS) support for the instagram-private-api
MIT License
244 stars 49 forks source link

Can i receive likes and comments on my post? #87

Closed gornostay25 closed 2 years ago

gornostay25 commented 2 years ago

How to receive comments and likes? Is its possible? I think I need to use this code https://github.com/Nerixyz/instagram_mqtt/blob/62eb5e98b509e0365c8795bbc9d81ec2d3f2789b/examples/realtime.example.ts#L92 But I don't know what is "broadcast-id"

Nerixyz commented 2 years ago

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.

gornostay25 commented 2 years ago

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

Nerixyz commented 2 years ago

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.

gornostay25 commented 2 years ago

@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);
}
Nerixyz commented 2 years ago

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.