I've launched a Heroku application using the following files:-
app.js
'use strict'
const express = require('express')
const bodyParser = require('body-parser')
const request = require('request')
const app = express()
app.set('port', (process.env.PORT || 5000))
// Process application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}))
// Process application/json
app.use(bodyParser.json())
// Index route
app.get('/', function (req, res) {
res.send("Hello world, I seem to be working")
})
// for Facebook verification
app.get('/webhook', function (req, res) {
if (req.query['hub.verify_token'] === 'test-token') {
res.send(req.query['hub.challenge']);
} else {
res.send('Error, wrong validation token');
}
})
// Spin up the server
app.listen(app.get('port'), function() {
console.log('running on port', app.get('port'))
})
.gitignore
node_modules
package.json
{
"name": "heroku-node-practice",
"version": "1.0.0",
"description": "New bot",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "Paigal",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2",
"foobar": "^1.1.0",
"mongoose": "^4.9.8",
"request": "^2.81.0"
}
}
Procfile
web: node app.js
I installed node.js dependencies using the command: npm install express request body-parser --save
After git push heroku master
, the application launches correctly.
However, when trying to set up a webhook in fb developer, the error is 'URL couldn't be validated. Response does not match expected challenge' then gives the different responses to the challenge. That is, my URL responds with "Hello world, I seem to be working" instead of numerical key.
Would greatly appreciate your help!