Skip to content

Instantly share code, notes, and snippets.

@vivahiraj
Created April 4, 2017 13:07
Show Gist options
  • Save vivahiraj/bfe6b9d2c5d0a093684db344be95f6e4 to your computer and use it in GitHub Desktop.
Save vivahiraj/bfe6b9d2c5d0a093684db344be95f6e4 to your computer and use it in GitHub Desktop.
LINE Messaging APIを試すためのAWS Lambdaファンクションです
var https = require('https');
exports.handler = function(event, context) {
console.log('Received event:', JSON.stringify(event, null, 2));
var reply_token = event.events[0].replyToken;
var data = JSON.stringify({
replyToken: reply_token,
messages:[
{
"type": "text",
"text": event.events[0].message.text
}
]
});
var opts = {
host: 'api.line.me',
path: '/v2/bot/message/reply',
headers: {
"Content-type": "application/json; charset=UTF-8",
"Authorization": " Bearer " + "Channel Access Token"
},
method: 'POST'
};
var req = https.request(opts, function(res){
res.on('data', function(chunk){
console.log(res.statusCode + 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