Closed cviejo closed 6 years ago
Never mind what I wrote before, it looks like FB may have recently changed this endpoint and it doesn't return in the same format now (YAY more API changes).
Looking in to it, potentially with @Alex-Rose
Noob question - are you using a fix API version, or just use the latest API available?
@thinkedem Facebook doesn't have an official chat API anymore, we're just ready the raw data from the requests and parsing it ourselves. Hence why we don't get a heads-up when it changes
Also affected by this. Good luck with it, pity they make it so hard for people to use their chat system in untraditional ways.
Is there any workaround for this issue?
Just an update on this, I figure we may need a hand at resolving this fast since it's a breaking change. What we normally when the API changes (or what we did originally) was fire up messenger.com, run chrome dev tools to see the network calls and find which call had the data for whatever we needed, parse it and use it in our app.
It used to be that messenger.com made a call to /threadlist_info.php
. And that returned a JSON blob we parsed. That endpoint has been completely retired. In favor of a call to a GraphQl general endpoint. Though surprisingly this time, I can't seem to be able to find it... Once we find the right call, fixing this is pretty easy.
Sorry for the slow pace...
For what it's worth, for me it looks like this information is hardcoded into the initial html page load of messenger.com inside a script tag. Try doing a search for last_message
and you get something like:
"last_message":{"nodes":[{"snippet":"test message pls ignore","message_sender":{"messaging_actor":{"id":"1639094490"}},"timestamp_precise":"1516322793736","commerce_message_type":null,"extensible_attachment":null,"sticker":null,"blob_attachments":[]}]}
@davepagurek's observation is about the best lead I can see. I hope it's still feasible to do this?
@insideClaw I've never worked with this code, but I may try to fix the issue over the weekend - I'm missing this app!
Hey all! I have a fix for this. Sorry it took so long, we've been busy with other work. Right now this is committed in the "chromium" branch with this commit 0a1cfe3fb619639793368ef7190a8e4c44ebdc66
The chromium branch fixes this bug, but also replaces PhantomJS with Google Puppeteer for the login. Give it a go, and give us some feedback, we'll do a little bit more polishing before we push an actual new version. But it now works.
@SamBergeron Thanks a lot for this! Everything works great again!
You'll notice the /groups command doesn't work anymore, and all the conversations are integrated together (which is actually a feature a lot of people wanted) because of the way we now fetch threads.
If there are other issues, we've also upgraded the error handling in that branch so it should be a bit easier to track down as well.
Today I am testing it on another computer (same configuration) and getting this error while log in:
Attempting login...
Error while logging in Error: Node is not visible
Login verification failed: Error: Node is not visible
Sorry if it's error on my side.
The Chromium branch doesn't really help here. I uninstalled the regular fb-messenger-cli global module, downloaded the chromium branch and tried running node cli.js
leading to another:
Found error while fetching conversations. TypeError: Cannot read property 'length' of undefined
I tried running the chromium branch, however it spits out: "Error while logging in Error: kill ESRCH" and "Login verification failed: TypeError: Cannot read property 'close' of undefined when attempting to login. Running latest npm and node on WSL.
@jathanasiou Reproduced it. It was when the last message sent in one of you conversations was an emoji. The snippet was undefined and threw an error.
We haven't pushed this branch to the main yet exactly due to little quirks like this, so if you guys keep testing it, post the error message (with the stack ideally) and we can try and fix it all as fast as possible.
@janfitz if you're getting the node is not visible
error, it's a timing issue I'm looking into. modifying the settings to have headlessLogin
set to false tends to solve it (you'll see puppeteer work and it tends to run a bit slower... Investigating it.
This is it bois. Older C apps would crash due to missing /EOF
characters. Now we're approaching the day when an entire web stack leading to an SQL query will crash due to a single unhandled emoji.
curl -X GET "http://awesome.company.com:8000/api/orders/😐
@jathanasiou want to try this one a549e1c2d1a9ae0bf08b0c659c6187fa765934ae
@SamBergeron I was getting the "Node is not visible" error like @janfitz so I tried fixing it as per the Puppeteer issue here. I've opened a PR.
EDIT: clarification, the app now logs me in normally, though I haven't thoroughly tested the chatting functionality.
@SamBergeron I am testing latest commits. Only one problem is that sometimes isn't new message notified in the top bar but after going back to conversation list using /menu
are all new messages downloaded correctly.
@janfitz as in the heading isn't updating properly? I've noticed that as well, but I think that was there before.
I'm going to merge this branch into the main branch and then close this defect though, feel free to open a new one for the heading not updating properly when I do that. I'll try and get it done today. Thanks man!
@SamBergeron Exactly, this is how the problem looks like. Thank you very much for your work, fb-messenger-cli is great app!
Merged everything into main this morning as well as published version 2.0 to npm. Please open new issues for new findings!
Thanks for being so patient!
Unfortunately same error in version 2.0 :(
user # npm view fb-messenger-cli version 2.0.0
user # fb-messenger-cli
Login verification failed: No saved profile, please login Facebook credentials: Email: test Password: Attempting login... Error while logging in AssertionError [ERR_ASSERTION]: Chromium revision is not downloaded. Run "npm install" Login verification failed: TypeError: Cannot read property 'close' of undefined
That's not the same error, what you have is a login Error.
Error while logging in AssertionError [ERR_ASSERTION]: Chromium revision is not downloaded. Run "npm install"
Make sure Puppeteer is installed (via npm install) and if that still doesn't work, make sure chromium can actually run on your machine (it has issues with some architectures, it might be worth pointing our what you're trying to run this on)
I got :
Attempting login... Error while logging in Error: kill ESRCH Login verification failed: TypeError: Cannot read property 'close' of undefined
In Ubuntu 16.04.3 LTS in WSL
I sill got:
Found error while fetching conversations. TypeError: Cannot read property 'length' of undefined at Messenger.saveParticipantsAsFriends (/usr/local/lib/node_modules/fb-messenger-cli/scripts/messenger.js:69:36) at Request.request.post [as _callback] (/usr/local/lib/node_modules/fb-messenger-cli/scripts/messenger.js:480:12) at Request.self.callback (/usr/local/lib/node_modules/fb-messenger-cli/node_modules/request/request.js:186:22) at emitTwo (events.js:126:13) at Request.emit (events.js:214:7) at Request.<anonymous> (/usr/local/lib/node_modules/fb-messenger-cli/node_modules/request/request.js:1163:10) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Gunzip.<anonymous> (/usr/local/lib/node_modules/fb-messenger-cli/node_modules/request/request.js:1085:12) at Object.onceWrapper (events.js:313:30)
No 2FA active
Response body looks like this: