I was trying to use the facebook messenger problem. I got stuck at the point where FB suggests the creation of a quick node js server app to do the verification for web hooks.
At one point, the docs, recommend doing this command.
> curl --insecure -X GET
> "http://localhost:1337/webhook?hub.verify_token=<TOKENSTRING>&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"
I am getting error like this
in visual studio curl request.
write EPROTO 1975128920:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:
in direct curl
Forbidden
Ultimately, I did not find a direct solution and found out the problem was this line of code.
app.listen(process.env.PORT || 1337, () => console.log('webhook is listening' + process.env.PORT));
for some reason, on my computer, the default port was undefined. Yet, the code did not skip over and pick 1337. It continue to run the server on the undefined port, essentially not running it, I guess.
I changed the code to this.
app.listen(1337, () => console.log('webhook is listening' + process.env.PORT));
This solved the issue.
I have put my copy of the full code here - https://github.com/Jay-study-nildana/FBMessengerWebHook, if anyone wants to use it.
Also, look at this curl command
curl --insecure -X GET "http://localhost:1337/webhook?hub.verify_token=<token>&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"
I also think --insecure makes a difference because, by default, at least on my computer, curl keeps looking for the https version of endpoint, which is simply not available at that point of code development.