EC2 Default User

ADD : push.js

Showing 1 changed file with 81 additions and 0 deletions
1 +const request = require('request');
2 +const TARGET_URL = 'https://api.line.me/v2/bot/message/push'
3 +const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast'
4 +const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast'
5 +const TOKEN = '채널 토큰으로 교체'
6 +const USER_ID = '사용자의 ID, 메세지 수신 시에 확인할 수 있음'
7 +
8 +//Single User -> 특정 인물 한명에게만 user_id
9 +/*
10 +request.post(
11 + {
12 + url: TARGET_URL,
13 + headers: {
14 + 'Authorization': `Bearer ${TOKEN}`
15 + },
16 + json: {
17 + "to": `${USER_ID}`,
18 + "messages":[
19 + {
20 + "type":"text",
21 + "text":"Hello, user"
22 + },
23 + {
24 + "type":"text",
25 + "text":"May I help you?"
26 + }
27 + ]
28 + }
29 + },(error, response, body) => {
30 + console.log(body)
31 + });
32 +*/
33 +
34 +// Multicast User -> 채널에 불특정 다수에게(user_id적힌 사람들에게)
35 +/*
36 +request.post(
37 + {
38 + url: MULTI_TARGET_URL,
39 + headers: {
40 + 'Authorization': `Bearer ${TOKEN}`
41 + },
42 + json: {
43 + "to": [`${USER_ID}`],
44 + "messages":[
45 + {
46 + "type":"text",
47 + "text":"Hello, user"
48 + },
49 + {
50 + "type":"text",
51 + "text":"May I help you?"
52 + }
53 + ]
54 + }
55 + },(error, response, body) => {
56 + console.log(body)
57 + });
58 +*/
59 +
60 +// Broadcast -> 채널 전체 유저에게
61 + request.post(
62 + {
63 + url: BROAD_TARGET_URL,
64 + headers: {
65 + 'Authorization': `Bearer ${TOKEN}`
66 + },
67 + json: {
68 + "messages":[
69 + {
70 + "type":"text",
71 + "text":"Hello, user"
72 + },
73 + {
74 + "type":"text",
75 + "text":"May I help you?"
76 + }
77 + ]
78 + }
79 + },(error, response, body) => {
80 + console.log(body)
81 + });
...\ No newline at end of file ...\ No newline at end of file