Showing
2 changed files
with
24 additions
and
2 deletions
1.24 KB
| 1 | +const app = require('koa') | ||
| 1 | function getRecommend(auth) { | 2 | function getRecommend(auth) { |
| 2 | console.log("login success", auth); | 3 | console.log("login success", auth); |
| 3 | - const host = 'http://localhost:23023'; | 4 | + const host = 'https://localhost:23023'; |
| 4 | const url = host+"/api/profile/recommend"; | 5 | const url = host+"/api/profile/recommend"; |
| 6 | + | ||
| 5 | const data = { username: 'test' }; | 7 | const data = { username: 'test' }; |
| 6 | window.fetch(url, { | 8 | window.fetch(url, { |
| 7 | method: "POST", | 9 | method: "POST", |
| ... | @@ -16,10 +18,31 @@ function getRecommend(auth) { | ... | @@ -16,10 +18,31 @@ function getRecommend(auth) { |
| 16 | }) | 18 | }) |
| 17 | .then(shareToKakao); | 19 | .then(shareToKakao); |
| 18 | } | 20 | } |
| 21 | +const TOKEN = 'tdN03DyXDAcKGZsuiPndaU7UC2GzuEQYUhPCkDnGWXGGdiPmV15QYbFU1U5JP5EpiETIKLqOmci/RxFZTfD7FRMED0OpT+3qgEYBNf8T9/jRzHRm7rblBLtzFBVOeXeYRcluOsz4koE4JaAJaUtMtwdB04t89/1O/w1cDnyilFU=' | ||
| 19 | 22 | ||
| 20 | function shareToKakao({problem_number, problem_title, solved_date}) { | 23 | function shareToKakao({problem_number, problem_title, solved_date}) { |
| 21 | console.log('getting ready to share...'); | 24 | console.log('getting ready to share...'); |
| 22 | const boj_link = "https://acmicpc.net/problem/" + problem_number.toString(); | 25 | const boj_link = "https://acmicpc.net/problem/" + problem_number.toString(); |
| 26 | + window.fetch('https://www.osstest17.ml:23023/hook', { | ||
| 27 | + method: "POST", | ||
| 28 | + body: JSON.stringify(data), | ||
| 29 | + headers: { | ||
| 30 | + 'Authorization': `Bearer ${TOKEN}` | ||
| 31 | + }, | ||
| 32 | + json: { | ||
| 33 | + "replyToken":eventObj.replyToken, | ||
| 34 | + "messages":[ | ||
| 35 | + { | ||
| 36 | + "type":"text", | ||
| 37 | + "text":"Hello, user" | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "type":"text", | ||
| 41 | + "text":"May I help you?" | ||
| 42 | + } | ||
| 43 | + ] | ||
| 44 | + } | ||
| 45 | + }) | ||
| 23 | window.Kakao.Link.sendDefault({ | 46 | window.Kakao.Link.sendDefault({ |
| 24 | objectType: 'text', | 47 | objectType: 'text', |
| 25 | text: `오늘의 추천문제는 ${problem_title}`, | 48 | text: `오늘의 추천문제는 ${problem_title}`, |
| ... | @@ -29,7 +52,6 @@ function shareToKakao({problem_number, problem_title, solved_date}) { | ... | @@ -29,7 +52,6 @@ function shareToKakao({problem_number, problem_title, solved_date}) { |
| 29 | } | 52 | } |
| 30 | }); | 53 | }); |
| 31 | } | 54 | } |
| 32 | - | ||
| 33 | export { | 55 | export { |
| 34 | getRecommend as default | 56 | getRecommend as default |
| 35 | }; | 57 | }; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment