こちら のサイトで紹介されていたコードをまずはそのまま実行してみようとしてみました。
javascript
1var https = require('https'); 2var querystring = require('querystring'); 3 4exports.handler = (event, context, callback) => { 5 event.events.forEach(function(res) { 6 var postData = JSON.stringify({ 7 "replyToken": res.replyToken, 8 "messages": [ 9 { 10 type: 'text', 11 text: getResponseMessage(res.message.text), 12 } 13 ] 14 }); 15 var ChannelAccessToken = '自前のChannel Access Token'; 16 var options = { 17 hostname: 'api.line.me', 18 path: '/v2/bot/message/reply', 19 port: 443, 20 method: 'POST', 21 headers: { 22 'Content-Type': 'application/json', 23 'Authorization': `Bearer ${ChannelAccessToken}` 24 } 25 }; 26 var req = https.request(options, (res) => { 27 res.on('data', (chunk) => { 28 console.log(`data: ${chunk}`); 29 }); 30 res.on('end', () => { 31 console.log('No more data in response.'); 32 }); 33 }); 34 req.on('error', (e) => { 35 console.log(`Problem with request: ${e.message}`); 36 }); 37 req.write(postData); 38 req.end(); 39 }); 40 callback(null, 'Success!'); 41}; 42 43var getResponseMessage = function(message) { 44 return message; 45}
#設定したこと
0. LINE DevelopersのBasicInformationからWebhook URLに、API GATEWAYのダッシュボードから確認できるURLを入力
0. API GATEWAYのリソースからPOSTメソッドを追加
#確認できたこと
0. Webhook URLのVERIFYの結果が”A http status of the response was '403 Forbidden'.”
0. API GATEWAYのダッシュボードでAPI呼び出しがカウントされている。しかしすべて4xx エラー。
Node.jsもlambdaも触ったのは今回が初めてなので、質問の仕方がかなり雑になってしまいました。今回の問題を解決するために勉強する必要がある点だけでもいいので教えてくださると助かります。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。