Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.93k stars 596 forks source link

Share does not show up #625

Open lekoOwO opened 6 years ago

lekoOwO commented 6 years ago

using npm install --save Schmavery/facebook-chat-api. when sharing link, console only gets info listen Got answer in (number) but no new events incoming.

23phy commented 6 years ago
const fs = require('fs');
const login = require('facebook-chat-api');

login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
    if (err) {
        return console.error(err);
    }

    api.listen((err, message) => {
        if(err) {
            return console.error(err);
        }

        api.setOptions({
            listenEvents: true,
            updatePresence: true
        });

        console.log("The message is: ", message);
    });
});
PS SomewhereInThisUniverse> node .\main.js
info login Logged in
info login Request to reconnect
info login Request to pull 1
info login Request to pull 2
info login Request to thread_sync
info login Done logging in.
info listen Got answer in 1019
info listen Got answer in 290
info listen Got answer in 8507
info listen Got answer in 342
The message is:  { type: 'message', // This is when I send a simple message
  senderID: 'randomNumber',
  body: 'Hmm',
  threadID: 'randomNumber',
  messageID: 'mid.$randomLetters',
  attachments: [],
  mentions: {},
  timestamp: 'randomNumber',
  isGroup: false }
info listen Got answer in 8084
info listen Got answer in 1286      // When I send a "share" the console.log should appear here with the message
info listen Got answer in 275       // or here and it doesn't. This happens only for the "share" attachment type
info listen Got answer in 357       // the rest work just fine, tested all of them
ravkr commented 6 years ago

@23phy you should use api.setOptions before api.listen, it is unnecessary to set it every time new event/message shows up...

23phy commented 6 years ago

@ravkr you're right, thank you, I noticed that a while ago.