Showing
4 changed files
with
60 additions
and
0 deletions
app - notify.js
0 → 100644
| 1 | +const request = require('request'); | ||
| 2 | +// 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요. | ||
| 3 | +const TARGET_URL = 'https://notify-api.line.me/api/notify'; | ||
| 4 | +const TOKEN = 'Kyu6Mp5GjB1afXWjKPqFdhdBxDicsxGBPrWp9s6JuxS'; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +/// 아래는 replytoken이 필요해 사용할수 없었습니다 | ||
| 9 | +//const CHANNEL_TOKEN | ||
| 10 | +//const line = require('@line/bot-sdk'); | ||
| 11 | +//const client = new line.Client({ | ||
| 12 | +// channelAccessToken: CHANNEL_TOKEN | ||
| 13 | +// }); | ||
| 14 | +//const message = { | ||
| 15 | +// type: 'text', | ||
| 16 | +// text: 'Hello World!' | ||
| 17 | +// }; | ||
| 18 | +// client.replyMessage('<replyToken>', message); | ||
| 19 | + //replytoken webhook | ||
| 20 | +/// | ||
| 21 | + | ||
| 22 | + var result; | ||
| 23 | + var AWS = require("aws-sdk"); | ||
| 24 | + AWS.config.update({region:'us-east-1'}); | ||
| 25 | + var params={LanguageCode:'en',TextList:['this is english']}; | ||
| 26 | + var comprehend = new AWS.Comprehend(); | ||
| 27 | + comprehend.batchDetectSentiment(params, function (err, data) { | ||
| 28 | + if (err) console.log(err, err.stack); // an error occurred | ||
| 29 | + else {console.log(data.ResultList[0]); | ||
| 30 | + result=data.ResultList[0]; | ||
| 31 | + send(result['Sentiment']); | ||
| 32 | + } // successful response | ||
| 33 | + }); | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| 39 | +function send(result){ | ||
| 40 | + request.post( | ||
| 41 | + | ||
| 42 | + { | ||
| 43 | + url: TARGET_URL, | ||
| 44 | + headers: { | ||
| 45 | + 'Authorization': `Bearer ${TOKEN}` | ||
| 46 | + }, | ||
| 47 | + form: { | ||
| 48 | + message: result, | ||
| 49 | + stickerPackageId: 1, | ||
| 50 | + stickerId: 1 | ||
| 51 | + } | ||
| 52 | + },(error, response, body) => { | ||
| 53 | + console.log(body) | ||
| 54 | + }); | ||
| 55 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
readme-build.txt
0 → 100644
캡처1.PNG
0 → 100644
132 KB
캡처2.PNG
0 → 100644
80.4 KB
-
Please register or login to post a comment