मैं निम्न फ़ाइलों का उपयोग कर एक Heroku आवेदन शुरू की है: -
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
मैं आदेश का उपयोग Node.js निर्भरता स्थापित: npm install express request body-parser --save
बाद git push heroku master, आवेदन सही ढंग से लॉन्च किया गया।
हालांकि, जब अमेरिकन प्लान डेवलपर में एक webhook स्थापित करने के लिए कोशिश कर रहा है, त्रुटि 'यूआरएल सत्यापित नहीं किया जा सकता है। प्रतिक्रिया की उम्मीद चुनौती से मेल नहीं खाता 'फिर चुनौती के लिए अलग अलग प्रतिक्रियाएं देता है। यही कारण है, मेरी यूआरएल के साथ संख्यात्मक कुंजी के बजाय नमस्ते दुनिया, मैं काम करने लगते हैं प्रतिक्रिया करता है।
बहुत आपकी मदद की सराहना करते हैं!













