Nerixyz / instagram_mqtt

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

[Q] Can I be notified of new posts and stories? #86

Closed ablearthy closed 2 years ago

ablearthy commented 2 years ago

Can I be notified of new posts and stories? Instagram Android application lets users to get notifications about new posts and stories (source) I've reverse engineered Instagram Android application and found that when a user switches toggle buttons (Posts, Stories, IGTV, Reels) some requests have to be sent. Example (the request is sent when a user switches Stories button):

const { body } = await ig.request.send({
    url: `/api/v1/friendships/favorite_for_stories/<target_id>/`,
    method: 'POST',
    form: ig.request.sign({
        user_id: "<target_id>",
        _uid: "<subscriber_id (i.e. self user_id)>",
        _uuid: ig.state.uuid
    })
});
console.log(body); // should print { 'status': 'ok' }

I've tried to subscribe for notifications after auth event, but after posting new story nothing happened. I copy/pasted this example and added the code above after 29 line. Is it possible to be notified of new posts and stories using this library?

Nerixyz commented 2 years ago

Is it possible to be notified of new posts and stories using this library?

Yes. Though as you may noticed, the notifications are often delayed or may not get sent at all.

I've tried to subscribe for notifications after auth event, but after posting new story nothing happened.

You only need to do that for your account once. There's no real identifier for the connection.

ablearthy commented 2 years ago

You only need to do that for your account once. There's no real identifier for the connection.

Yes, it is. I tried to send stories multiple times but there's no output. Other notifications coming in (at least notifications about new direct messages). That's kind of strange that I don't receive notifications about new stories after several attempts. Is it possible that the library skips such notifications?

Nerixyz commented 2 years ago

Is it possible that the library skips such notifications?

No. It may be that these are not sent to the client but no notifications are skipped.

ablearthy commented 2 years ago

Ok, thanks. I will continue to research.

ablearthy commented 2 years ago

Finally, I got the notification. Thanks for your response!

Probably, I haven't received notifications due to the open emulator. Since it works I will rewrite this library to Python

adityaa-codes commented 2 years ago

Hi, @ablearthy it'd be awesome, if you can provide endpoints & params to turn on post, video and reels notifications. Thanks in Advance