Showing
1 changed file
with
7 additions
and
10 deletions
... | @@ -25,21 +25,17 @@ app.post('/hook', function (req, res) { | ... | @@ -25,21 +25,17 @@ app.post('/hook', function (req, res) { |
25 | console.log('[request source] ', eventObj.source); | 25 | console.log('[request source] ', eventObj.source); |
26 | console.log('[request message]', eventObj.message); | 26 | console.log('[request message]', eventObj.message); |
27 | 27 | ||
28 | - trans(eventObj.replyToken, eventObj.message.text); | 28 | + movielist(eventObj.replyToken, eventObj.message.text); |
29 | - | ||
30 | 29 | ||
31 | res.sendStatus(200); | 30 | res.sendStatus(200); |
32 | }); | 31 | }); |
33 | 32 | ||
34 | -// message insert: Inquiry start opening year,Inquiry end opening year | 33 | + |
35 | -// ex) 2019,2020 | 34 | +function movielist(replyToken, message) { |
36 | -function trans(replyToken, message) { | 35 | + var encodedMessage = encodeURI(message); |
37 | - var my_message, copied_message; | ||
38 | - copied_message = message | ||
39 | - my_message = copied_message.split(','); | ||
40 | request.get( | 36 | request.get( |
41 | { | 37 | { |
42 | - url: KOFIC_URL+`?key=${config.KOFIC_KEY}&openStartDt=${my_message[0]}&openEndDt=${my_message[1]}}`, | 38 | + url: KOFIC_URL+`?key=${config.KOFIC_KEY}&movieNm=${encodedMessage}`, |
43 | json:true | 39 | json:true |
44 | },(error, response, body) => { | 40 | },(error, response, body) => { |
45 | if(!error && response.statusCode == 200) { | 41 | if(!error && response.statusCode == 200) { |
... | @@ -48,13 +44,14 @@ function trans(replyToken, message) { | ... | @@ -48,13 +44,14 @@ function trans(replyToken, message) { |
48 | for (let i = 0; i < body.movieListResult.movieList.length; i ++){ | 44 | for (let i = 0; i < body.movieListResult.movieList.length; i ++){ |
49 | movieNm = body.movieListResult.movieList[i].movieNm; | 45 | movieNm = body.movieListResult.movieList[i].movieNm; |
50 | prdtYear = body.movieListResult.movieList[i].prdtYear; | 46 | prdtYear = body.movieListResult.movieList[i].prdtYear; |
47 | + movieCd = body.movieListResult.movieList[i].movieCd; | ||
51 | if(body.movieListResult.movieList[i].directors.length === 0){ | 48 | if(body.movieListResult.movieList[i].directors.length === 0){ |
52 | directors = "감독정보없음" | 49 | directors = "감독정보없음" |
53 | } | 50 | } |
54 | else{ | 51 | else{ |
55 | directors = body.movieListResult.movieList[i].directors[0].peopleNm; | 52 | directors = body.movieListResult.movieList[i].directors[0].peopleNm; |
56 | } | 53 | } |
57 | - result += '제목: ' + movieNm + `(${prdtYear})` + '\n' + '감독: ' + directors + '\n'; | 54 | + result += '제목: ' + movieNm + `(${prdtYear})` + '\n' + '감독: ' + directors + '\n' + '영화코드: ' + movieCd + '\n'; |
58 | } | 55 | } |
59 | request.post( | 56 | request.post( |
60 | { | 57 | { | ... | ... |
-
Please register or login to post a comment