Showing
1 changed file
with
29 additions
and
27 deletions
... | @@ -7,17 +7,17 @@ const Result_URL = 'https://inspct.career.go.kr/openapi/test/report' | ... | @@ -7,17 +7,17 @@ const Result_URL = 'https://inspct.career.go.kr/openapi/test/report' |
7 | const fs = require('fs'); | 7 | const fs = require('fs'); |
8 | const path = require('path'); | 8 | const path = require('path'); |
9 | const HTTPS = require('https'); | 9 | const HTTPS = require('https'); |
10 | -const domain = "www.ahhhhhhhh.tk" | 10 | +const domain = "www.skdhkfkdy.tk" |
11 | const sslport = 23023; | 11 | const sslport = 23023; |
12 | const bodyParser = require('body-parser'); | 12 | const bodyParser = require('body-parser'); |
13 | const { stringify } = require('querystring'); | 13 | const { stringify } = require('querystring'); |
14 | const { ADDRGETNETWORKPARAMS } = require('dns'); | 14 | const { ADDRGETNETWORKPARAMS } = require('dns'); |
15 | var app = express(); | 15 | var app = express(); |
16 | app.use(bodyParser.json()); | 16 | app.use(bodyParser.json()); |
17 | -var ans_sheet="", i, question, answer, contents, result; | 17 | +var ans_sheet="", i, question, answer, contents, result, eventObj, message, timestamp; |
18 | app.post('/hook', function (req, res) { | 18 | app.post('/hook', function (req, res) { |
19 | - var eventObj = req.body.events[0]; | 19 | + eventObj = req.body.events[0]; |
20 | - var message = eventObj.message; | 20 | + message = eventObj.message; |
21 | console.log('======================', new Date() ,'======================'); | 21 | console.log('======================', new Date() ,'======================'); |
22 | console.log('[request]', req.body); | 22 | console.log('[request]', req.body); |
23 | console.log('[request source] ', eventObj.source); | 23 | console.log('[request source] ', eventObj.source); |
... | @@ -25,6 +25,7 @@ app.post('/hook', function (req, res) { | ... | @@ -25,6 +25,7 @@ app.post('/hook', function (req, res) { |
25 | if (message.text=="시작"){ | 25 | if (message.text=="시작"){ |
26 | i=0; | 26 | i=0; |
27 | ans_sheet=""; | 27 | ans_sheet=""; |
28 | + timestamp=eventObj.timestamp; | ||
28 | request.get({ | 29 | request.get({ |
29 | url:Question_URL | 30 | url:Question_URL |
30 | },function(err,res,body){ | 31 | },function(err,res,body){ |
... | @@ -40,6 +41,7 @@ app.post('/hook', function (req, res) { | ... | @@ -40,6 +41,7 @@ app.post('/hook', function (req, res) { |
40 | json: { | 41 | json: { |
41 | "replyToken":eventObj.replyToken, | 42 | "replyToken":eventObj.replyToken, |
42 | "messages":[{ | 43 | "messages":[{ |
44 | + | ||
43 | "type":"text", | 45 | "type":"text", |
44 | "text":"직업가치관검사를 시작합니다(28문항)" | 46 | "text":"직업가치관검사를 시작합니다(28문항)" |
45 | },{ | 47 | },{ |
... | @@ -72,7 +74,7 @@ app.post('/hook', function (req, res) { | ... | @@ -72,7 +74,7 @@ app.post('/hook', function (req, res) { |
72 | "gender":"100323", | 74 | "gender":"100323", |
73 | "school":"경희대학교", | 75 | "school":"경희대학교", |
74 | "grade":"2", | 76 | "grade":"2", |
75 | - "startDtm":1550466291034, | 77 | + "startDtm":timestamp, |
76 | "answers":ans_sheet | 78 | "answers":ans_sheet |
77 | } | 79 | } |
78 | },(err,res,body)=>{ | 80 | },(err,res,body)=>{ |
... | @@ -105,28 +107,28 @@ app.post('/hook', function (req, res) { | ... | @@ -105,28 +107,28 @@ app.post('/hook', function (req, res) { |
105 | question = contents["RESULT"][i]["question"]; | 107 | question = contents["RESULT"][i]["question"]; |
106 | answer = contents["RESULT"][i]["answer01"]+"/"+contents["RESULT"][i]["answer02"]; | 108 | answer = contents["RESULT"][i]["answer01"]+"/"+contents["RESULT"][i]["answer02"]; |
107 | ans_sheet+="B"+i.toString()+"="; | 109 | ans_sheet+="B"+i.toString()+"="; |
108 | - request.post({ | 110 | + request.post({ |
109 | - url: TARGET_URL, | 111 | + url: TARGET_URL, |
110 | - headers: { | 112 | + headers: { |
111 | - 'Authorization': `Bearer ${TOKEN}` | 113 | + 'Authorization': `Bearer ${TOKEN}` |
112 | - }, | 114 | + }, |
113 | - json: { | 115 | + json: { |
114 | - "replyToken":eventObj.replyToken, | 116 | + "replyToken":eventObj.replyToken, |
115 | - "messages":[ | 117 | + "messages":[ |
116 | - { | 118 | + { |
117 | - "type":"text", | 119 | + "type":"text", |
118 | - "text":(i+1).toString()+". "+question | 120 | + "text":(i+1).toString()+". "+question |
119 | - },{ | 121 | + },{ |
120 | - "type":"text", | 122 | + "type":"text", |
121 | - "text":answer | 123 | + "text":answer |
122 | - },{ | 124 | + },{ |
123 | - "type":"text", | 125 | + "type":"text", |
124 | - "text":"답변은 1 또는 2로 해주세요" | 126 | + "text":"답변은 1 또는 2로 해주세요" |
125 | - }] | 127 | + }] |
126 | - } | 128 | + } |
127 | - },(error, response, body) => { | 129 | + },(error, response, body) => { |
128 | - i+=1; | 130 | + i+=1; |
129 | - }); | 131 | + }); |
130 | }); | 132 | }); |
131 | } | 133 | } |
132 | }else if (message.text=="종료") { | 134 | }else if (message.text=="종료") { | ... | ... |
-
Please register or login to post a comment