Nerixyz / instagram_mqtt

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

Unable to fetch realtime comments and view count for live video broadcast #91

Closed ctle-vn closed 2 years ago

ctle-vn commented 2 years ago

Using the code from the realtime example, here's my adapted code:

  try {
    console.log(`Startaing realtime with broadcast id: ${broadcast_id}`)
    const ig: IgApiClientRealtime = withRealtime(new IgApiClient())
    console.log('Startaing realtime2.')
    ig.state.generateDevice(ig_username)
    console.log('Startaing realtime3.')
    await ig.account.login(ig_username, ig_password)
    console.log('Startaing realtime4.')
    const liveRealtimeCommentsSubscription = GraphQLSubscriptions.getLiveRealtimeCommentsSubscription(broadcast_id)
    console.log(
      `Startaing realtime5, ${JSON.stringify(
        liveRealtimeCommentsSubscription,
      )}, ${typeof liveRealtimeCommentsSubscription}`,
    )
    const sub = await ig.realtime.graphQlSubscribe(liveRealtimeCommentsSubscription)
    console.log(`GraphQL subscription: ${JSON.stringify(sub)}`)
    return sub
  } catch (error) {
    console.log(`fucked up ${error}`)
    return {}
  }

Startaing realtime with broadcast id: Startaing realtime2. Startaing realtime3. Startaing realtime4. Startaing realtime5, "1/graphqlsubscriptions//{\"input_data\":{\"client_subscription_id\":\,\"broadcast_id\":\"\"}}", string fucked up TypeError: Cannot read property 'updateSubscriptions' of undefined

Am I doing something wrong here?

-- Also was wondering if there was a way for me to get the real time view count for a live video broadcast?

Nerixyz commented 2 years ago

You didn't connect the client. Only a connected client may sub to GQL.

Here you can see how to connect with GQL topics.

ctle-vn commented 2 years ago

Hey @Nerixyz ,

Thanks for the quick response. I've connected the client now, although I'm not entirely familiar with MQTT. I don't see anything being logged when trying to catch new comments on a live video broadcast.

Is there a way for me to pass a callback function whenever the subscribed topic has a new event triggered? Specifically, trigger a callback function when a live broadcast receives a new comment.

Nerixyz commented 2 years ago

You should listen to the liveRealtimeComments event (.on('liveRealtimeComments', ...)).

kkm commented 1 year ago

I also have the same problems