Facebook-chat-api: Can't send message

Created on 25 Feb 2018  路  10Comments  路  Source: Schmavery/facebook-chat-api

I have tried the echo bot example and it is thrown an error when I send a message to the bot.

The bot didn't reply my message and here is the error.
asd

and the code
qweasd

Most helpful comment

Thanks everyone! Feel free to follow up here if the fix doesn't work

All 10 comments

It's definitely working on my end, do you use this repository or the module on npm?

@23phy I use this repository.

Changed the module with this repo but.. still working to me.

github

Does accessing Facebook through your browser redirect to some subdomain like web.facebook.com?

Unfortunately, I don't yet know the cause of this (when I use api.sendMessage it works fine), but I think Toohpick is on the right track.
As a side note, isn't it potentially dangerous to be running a web script as root?

@Toohpick Yes, it does.
When I access https://www.facebook.com it always redirects to https://web.facebook.com.
So also with https://m.facebook.com always redirect to https://mobile.facebook.com.
Probably the redirection caused that error, right?

@chocorho Oh right that it is dangerous, just coincidentally I'm using root user.

Apologies for the very late reply. I managed to verify that the redirection is definitely the culprit here, but couldn't find why. I tried replicating the app's request on the browser but there was nothing wrong with its response. I'll try looking more into it when I have the time.
As a workaround, consider deploying your app to a web platform.

@Toohpick thanks for helping debug this issue. Does it seem like we're not handling redirection properly on the api side? I don't completely understand what you mean talking about "deploying your app to a web platform".

For some ISPs, Facebook does a redirection with the meta tag, which the request module doesn't pick up.
As for the workaround, I simply meant using a cloud platform such as heroku, as Facebook doesn't redirect on requests done from their server. Sorry for the confusion. I will submit a PR that seemed to fix this for me.

Thanks everyone! Feel free to follow up here if the fix doesn't work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KuoyuanY picture KuoyuanY  路  7Comments

StevenSuh picture StevenSuh  路  8Comments

WaffleCohn picture WaffleCohn  路  6Comments

ianw11 picture ianw11  路  7Comments

ezaca picture ezaca  路  3Comments