Created
April 23, 2016 13:36
-
-
Save vivahiraj/4e90c610c6baf8af9a7b5d6cb4ca1227 to your computer and use it in GitHub Desktop.
LINE BOT APIを試すためのAWS Lambdaファンクションです
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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