Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/177f41e9f8c45fbeedcc309120b9810a to your computer and use it in GitHub Desktop.
Save hisasann/177f41e9f8c45fbeedcc309120b9810a to your computer and use it in GitHub Desktop.
var express = require('express');
var router = express.Router();
var request = require('request');
const headers = {
'Content-Type' : 'application/json; charset=UTF-8',
'X-Line-ChannelID' : '<Channel ID>',
'X-Line-ChannelSecret' : '<Channel Secret>',
'X-Line-Trusted-User-With-ACL' : '<MID>'
};
const options = {
url: 'https://trialbot-api.line.me/v1/events',
proxy: process.env.FIXIE_URL,
headers: headers,
json: true,
body: null
};
router.post('/callback', function(req, res, next) {
var json = req.body;
var text = json['result'][0]['content']['text'];
var from = [json['result'][0]['content']['from']];
options.body = {
'to': from,
'toChannel': 1383378250, // fixed
'eventType':'138311608800106203', // fixed
'content': {
// text
'contentType': 1,
'toType': 1,
'text': '\(^o^)/'
}
};
request.post(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
} else {
console.log('error: '+ JSON.stringify(response));
}
});
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment