Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
Stock_Alert_Chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
EC2 Default User
2022-06-08 04:41:38 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e969e509eb9aedbecbba1bee620c39562d4c49e3
e969e509
1 parent
af98a008
ADD : push.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
push.js
push.js
0 → 100644
View file @
e969e50
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/push'
const
MULTI_TARGET_URL
=
'https://api.line.me/v2/bot/message/multicast'
const
BROAD_TARGET_URL
=
'https://api.line.me/v2/bot/message/broadcast'
const
TOKEN
=
'채널 토큰으로 교체'
const
USER_ID
=
'사용자의 ID, 메세지 수신 시에 확인할 수 있음'
//Single User -> 특정 인물 한명에게만 user_id
/*
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"to": `${USER_ID}`,
"messages":[
{
"type":"text",
"text":"Hello, user"
},
{
"type":"text",
"text":"May I help you?"
}
]
}
},(error, response, body) => {
console.log(body)
});
*/
// Multicast User -> 채널에 불특정 다수에게(user_id적힌 사람들에게)
/*
request.post(
{
url: MULTI_TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"to": [`${USER_ID}`],
"messages":[
{
"type":"text",
"text":"Hello, user"
},
{
"type":"text",
"text":"May I help you?"
}
]
}
},(error, response, body) => {
console.log(body)
});
*/
// Broadcast -> 채널 전체 유저에게
request
.
post
(
{
url
:
BROAD_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"Hello, user"
},
{
"type"
:
"text"
,
"text"
:
"May I help you?"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
\ No newline at end of file
Please
register
or
login
to post a comment