Ben aşağıdaki dosyaları kullanarak bir Heroku uygulamasını başlattık: -
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
Ben komutunu kullanarak node.js bağımlılıkları yüklü: npm install express request body-parser --save
Sonra git push heroku master, uygulama düzgün başlattı.
Ancak, fb geliştirici bir webhook kurmaya çalışırken, hata URL doğrulanamadı' dir. Tepki sonra meydan farklı tepkiler verir 'beklenen meydan eşleşmiyor. Bu benim URL yerine sayısal anahtar Merhaba dünya, ben çalışıyor gibi görünüyor yanıtını vardır.
büyük ölçüde yardımını takdir ederim!













