Skip to content

Instantly share code, notes, and snippets.

@vivahiraj
Created April 23, 2016 13:36
Show Gist options
  • Save vivahiraj/4e90c610c6baf8af9a7b5d6cb4ca1227 to your computer and use it in GitHub Desktop.
Save vivahiraj/4e90c610c6baf8af9a7b5d6cb4ca1227 to your computer and use it in GitHub Desktop.
LINE BOT APIを試すためのAWS Lambdaファンクションです
var https = require('https');
exports.handler = function(event, context) {
console.log('Received event:', JSON.stringify(event, null, 2));
var msg = event.result[0];
console.log('Message To', msg.content.from.toString());
var data = JSON.stringify({
to: [msg.content.from.toString()],
toChannel: 1383378250,
eventType: "138311608800106203",
content: msg.content
});
var url ='https://trialbot-api.line.me/v1/events';
var opts = {
host: 'trialbot-api.line.me',
path: '/v1/events',
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"
},
method: 'POST'
}
var req = https.request(opts, function(res){
res.on('data', function(chunk){
console.log(chunk.toString())
}).on('error', function(e){
console.log('ERROR: '+ e.stack);
})
})
req.write(data)
req.end();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment