ShinSeungMin

Add KakaoAPI feature

......@@ -17,9 +17,11 @@ var app = express();
app.use(bodyParser.json());
/////////////////////////////////////////////////
// commit 할때 지워야 할것들
const USER_ID = ''
const TOKEN = ''
const domain = ""
const USER_ID = '';
const TOKEN = '';
const domain = '';
const KAKAO_KEY = '';
/////////////////////////////////////////////////
let MEGA_date;
let MEGA_TheaterLocation;
......@@ -31,6 +33,7 @@ let initFlag = false; //브랜드 선택 flag
let MEGA_flag = -1; //메가박스 인지 확인하는 flag
let MEGA_count; //메가박스에서 영화관 판단하는 count
let MEGA_AbleLocationList = []; //메가박스에서 영화관 이름 매치하는 것 저장하는 list
let MegaboxKakaoResultTheater = [];
exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL;
////////////////////////////////////////////////
//처음 영화관을 가져오는 것까지 대략 30초가 걸림 => 30초 기다리고 메세지 전송
......@@ -213,15 +216,24 @@ app.post('/hook', asyncHandler(async (req, res, next) => {
const final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
console.log(final_URL);
PushMessage(final_URL, "링크를 누르면 예매창으로 바로 이동합니다.");
MEGA_PlayingMovieList = []; //영화 리스트 초기화
MegaboxKakaoResultTheater = [];
GetMegaboxKakaoMapURL(MEGA_TheaterLocation);
setTimeout(function () {
MEGA_PlayingMovieList = [];
console.log(MegaboxKakaoResultTheater[0]);
let MegaboxKakaoResultTheaterNAME = MegaboxKakaoResultTheater[0]['theater_name'];
let MegaboxKakaoResultTheaterURL = MegaboxKakaoResultTheater[0]['theater_url'];
console.log(MegaboxKakaoResultTheaterNAME, MegaboxKakaoResultTheaterURL);
PushMessage(MegaboxKakaoResultTheaterURL, "카카오맵으로 검색한 " + MegaboxKakaoResultTheaterNAME+ "의 위치입니다.");
setTimeout(function () {
//EGA_PlayingMovieList = [];
initFlag = false;
MEGA_flag = -1;
PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요.");
}, 1000);
}, 2000);
}
}
res.sendStatus(200);
}))
//});
......@@ -238,6 +250,45 @@ try {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
GetMegaboxKakaoMapURL= async(LOCATE) => {
let KAKAOOPTION = {
url: "https://dapi.kakao.com/v2/local/search/keyword",
method: "GET",
headers: {
'Authorization': `KakaoAK ${KAKAO_KEY}` // commit 할때 지워야 할것
},
qs: {
'query': '메가박스 ' + LOCATE, // 메가박스 영화관이름
//'category_group_code' : 'CT1',
'size': 5
},
encoding: 'UTF-8'
};
let selectable_theaters = [];
request(KAKAOOPTION, function (err, res, body) {
info_list = JSON.parse(body).documents;
if (!err && res.statusCode == 200) {
info_list.forEach(info => {
//console.log(info.category_name);
if (info.category_name.endsWith("메가박스")) {
const theater_info = {
"theater_name": info.place_name,
"theater_url": info.place_url
};
//console.log(theater_info);
//return theater_info;
selectable_theaters.push(theater_info);
}
});
}
console.log(selectable_theaters);
MegaboxKakaoResultTheater = selectable_theaters;
return;
});
}
//메세지 전송하는 function 모음
function SendMessage(eventObj, text1, text2 = "") { //reply message
request.post(
......
This diff could not be displayed because it is too large.
......@@ -16,7 +16,9 @@
"chromedriver": "^101.0.0",
"express": "^4.18.1",
"express-async-handler": "^1.2.0",
"moment": "^2.29.3",
"puppeteer": "^14.1.1",
"request": "^2.88.2",
"selenium-webdriver": "^4.1.2"
}
}
......