Showing
2 changed files
with
70 additions
and
30 deletions
cfr_module.js
0 → 100644
1 | +var client_id = 'v3M4wjolGLkrvNA3GUIW'; | ||
2 | +var client_secret = 'fKF6vjkWhE'; | ||
3 | +var fs = require('fs'); | ||
4 | +var request = require('request'); | ||
5 | +const path = require('path'); | ||
6 | +var express = require('express'); | ||
7 | +var app = express(); | ||
8 | +var domain = "www.osstest237.ml" | ||
9 | +const sslport = 23023; | ||
10 | +const HTTPS = require('https'); | ||
11 | + | ||
12 | +exports.imgtodata = function(dir){ | ||
13 | + var api_url = 'https://openapi.naver.com/v1/vision/face'; // 얼굴 감지 | ||
14 | + | ||
15 | + var _formData = { | ||
16 | + image:'image', | ||
17 | + image: fs.createReadStream(path.join(__dirname, dir)) // FILE 이름 | ||
18 | + }; | ||
19 | + | ||
20 | + request.post( | ||
21 | + { url:api_url, | ||
22 | + formData:_formData, | ||
23 | + headers: {'X-Naver-Client-Id':client_id, | ||
24 | + 'X-Naver-Client-Secret': client_secret} | ||
25 | + }, (err,response,body) =>{ | ||
26 | + console.log(response.statusCode); // 200 | ||
27 | + //console.log(response.headers['content-type']) | ||
28 | + | ||
29 | + data=JSON.parse(body); | ||
30 | + gender=data.faces[0].gender.value; | ||
31 | + emotion=data.faces[0].emotion.value | ||
32 | + | ||
33 | + console.log(gender); | ||
34 | + console.log(emotion); | ||
35 | + | ||
36 | + //return {gender:gender,emotion:emotion}; | ||
37 | + }); | ||
38 | + } | ||
39 | + | ||
40 | + try { | ||
41 | + const option = { | ||
42 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
43 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
44 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
45 | + }; | ||
46 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
47 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
48 | + }); | ||
49 | + } catch (error) { | ||
50 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
51 | + console.log(error); | ||
52 | +} | ||
53 | + | ||
54 | +//imgtodata('./test3.jpg'); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -3,12 +3,12 @@ var client_id = 'v3M4wjolGLkrvNA3GUIW'; | ... | @@ -3,12 +3,12 @@ var client_id = 'v3M4wjolGLkrvNA3GUIW'; |
3 | var client_secret = 'fKF6vjkWhE'; | 3 | var client_secret = 'fKF6vjkWhE'; |
4 | const request = require('request'); | 4 | const request = require('request'); |
5 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 5 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
6 | -const TOKEN = 'hMnfhBQc8nadyn5Ow6aejAVDUoUEp9N8YxOFxfOB2V83TOf0vjquT4cC8ll4Ccq4hkWJ8xHij53FzjMteqLLuUL6bZs+ZONI+f5aawIulRg4Y4FFBGp1O03awvgxGn503iyI7+5iQCEi80Kus6cRZQdB04t89/1O/w1cDnyilFU=' //수정해주세용 | 6 | +const TOKEN = 'w5i8sURqF5bof6DWeB87n+oCeWrYaFf7a5YZzfzN1jeITIlZ3PcOmZRcdGCo/djTuHhNxybfJ69y7Jex+7tipBNRynngfyWX9CK1L3EupuhnX8rubeCmJda7HvsQWXVo8ZDcwl2aLwXsE3kiYF2qEwdB04t89/1O/w1cDnyilFU=' //수정해주세용 |
7 | -const SECRET = '270103fd4cbd81695ceb6d0ed7f85f4b' //수정해주세용 | 7 | +const SECRET = 'b0b4501ebc2813a2b0e586293a35b466' //수정해주세용 |
8 | const fs = require('fs'); | 8 | const fs = require('fs'); |
9 | const path = require('path'); | 9 | const path = require('path'); |
10 | const HTTPS = require('https'); | 10 | const HTTPS = require('https'); |
11 | -const domain = "www.osschatbot.tk" //수정해주세용 | 11 | +const domain = "www.osstest237.ml" //수정해주세용 |
12 | const sslport = 23023; | 12 | const sslport = 23023; |
13 | const line = require('@line/bot-sdk'); | 13 | const line = require('@line/bot-sdk'); |
14 | 14 | ||
... | @@ -260,7 +260,7 @@ function QuickReplyCfrYes(replyToken) { | ... | @@ -260,7 +260,7 @@ function QuickReplyCfrYes(replyToken) { |
260 | "messages": [ | 260 | "messages": [ |
261 | { | 261 | { |
262 | "type": "text", | 262 | "type": "text", |
263 | - "text": "사진을 입력해주세요.", | 263 | + "text": "사진을 입력해주세요. 얼굴 인식이 되지 않을 경우 위치 기반으로 추천됩니다.", |
264 | "quickReply": quickReplyCfrYes | 264 | "quickReply": quickReplyCfrYes |
265 | } | 265 | } |
266 | ] | 266 | ] |
... | @@ -351,6 +351,12 @@ function RecommendationResult(replyToken, query) { | ... | @@ -351,6 +351,12 @@ function RecommendationResult(replyToken, query) { |
351 | roadAddress = data.items[0].roadAddress; | 351 | roadAddress = data.items[0].roadAddress; |
352 | console.log(roadAddress); | 352 | console.log(roadAddress); |
353 | 353 | ||
354 | + var x = Number(data.items[0].mapx); | ||
355 | + var y = Number(data.items[0].mapy); | ||
356 | + | ||
357 | + var longitude = TMtoWGS(x, y)[0]; | ||
358 | + var latitude = TMtoWGS(x, y)[1]; | ||
359 | + | ||
354 | request.post( | 360 | request.post( |
355 | { | 361 | { |
356 | url: TARGET_URL, | 362 | url: TARGET_URL, |
... | @@ -360,28 +366,13 @@ function RecommendationResult(replyToken, query) { | ... | @@ -360,28 +366,13 @@ function RecommendationResult(replyToken, query) { |
360 | json: { | 366 | json: { |
361 | "replyToken": replyToken, | 367 | "replyToken": replyToken, |
362 | "messages": [ | 368 | "messages": [ |
363 | - /*{ | ||
364 | - "type": "imagemap", | ||
365 | - // 이미지 불러올 수 없습니다 뜸 | ||
366 | - "baseUrl": "https://www.flaticon.com/free-icon/food-store_2934069?term=restaurant&page=1&position=7&related_item_id=2934069", | ||
367 | - "altText": "이미지를 누르시면 해당 가게로 이동합니다.", | ||
368 | - "baseSize": { | ||
369 | - "width": 1040, | ||
370 | - "height": 1040 | ||
371 | - }, | ||
372 | - "actions": [ | ||
373 | { | 369 | { |
374 | - "type": "uri", | 370 | + "type":"location", |
375 | - "linkUri": link, // 가게 링크 | 371 | + "title": title, |
376 | - "area": { | 372 | + "address": address, |
377 | - "x": 0, | 373 | + "latitude": latitude, |
378 | - "y": 0, | 374 | + "longitude": longitude |
379 | - "width": 1040, | 375 | + }, |
380 | - "height": 1040 | ||
381 | - } | ||
382 | - } | ||
383 | - ] | ||
384 | - },*/ | ||
385 | { | 376 | { |
386 | "type": "text", | 377 | "type": "text", |
387 | "text": "맛집 이름: " + title | 378 | "text": "맛집 이름: " + title |
... | @@ -390,11 +381,6 @@ function RecommendationResult(replyToken, query) { | ... | @@ -390,11 +381,6 @@ function RecommendationResult(replyToken, query) { |
390 | "type":"text", | 381 | "type":"text", |
391 | "text": "맛집 주소: " + address | 382 | "text": "맛집 주소: " + address |
392 | } | 383 | } |
393 | - /*{ | ||
394 | - "type":"location", | ||
395 | - "title":"맛집 주소", | ||
396 | - "address":address | ||
397 | - }*/ | ||
398 | ] | 384 | ] |
399 | } | 385 | } |
400 | }, (error, response, body) => { | 386 | }, (error, response, body) => { | ... | ... |
-
Please register or login to post a comment