@@ -4,13 +4,28 @@ const asyncify = require("express-asyncify");
44const { SolapiMessageService } = require ( "solapi" ) ;
55const messageService = new SolapiMessageService ( "ENTER_YOUR_API_KEY" , "ENTER_YOUR_API_SECRET" ) ;
66
7+ /**
8+ * 웹훅 레퍼런스
9+ * http://developers.solapi.com/references/webhook/
10+ */
11+
712// 넘어온 그룹 ID로 메시지 목록을 가져오는 API를 사용하므로 API Key, API Secret Key가 준비되어야 합니다.
813const app = asyncify ( express ( ) ) ;
914app . use ( bodyParser . json ( { extended : false } ) ) ;
1015app . use ( bodyParser . urlencoded ( { extended : false } ) ) ;
1116
12- // 관리콘솔 내 등록한 webhook url로 입력해야 합니다.
13- app . post ( "/report" , async ( req , res ) => {
17+ // 메시지 리포트
18+ app . post ( "/single-report" , async ( req , res ) => {
19+ // body에 [] 형식으로 메시지정보 객체 목록이 들어옵니다.
20+ for ( const messageInfo of req . body ) {
21+ console . log ( "메시지 정보:" , messageInfo ) ;
22+ }
23+ // 200을 리턴해야 합니다. (200이 리턴되지 않으면 특정 시간 간격을 두고 총 5번이 호출됩니다)
24+ return res . status ( 200 ) . json ( { } ) ;
25+ } ) ;
26+
27+ // 그룹 리포트
28+ app . post ( "/group-report" , async ( req , res ) => {
1429 // body에 [] 형식으로 그룹정보 객체 목록이 들어옵니다.
1530 for ( const groupInfo of req . body ) {
1631 // 그룹ID로 메시지 목록을 가져옵니다.
@@ -28,6 +43,16 @@ app.post("/report", async (req, res) => {
2843 return res . status ( 200 ) . json ( { } ) ;
2944} ) ;
3045
46+ // 팩스 수신
47+ app . post ( "/fax" , async ( req , res ) => {
48+ // body에 [] 형식으로 팩스수신정보 객체 목록이 들어옵니다.
49+ for ( const faxInfo of req . body ) {
50+ console . log ( "팩스 수신 정보:" , faxInfo ) ;
51+ }
52+ // 200을 리턴해야 합니다. (200이 리턴되지 않으면 특정 시간 간격을 두고 총 5번이 호출됩니다)
53+ return res . status ( 200 ) . json ( { } ) ;
54+ } ) ;
55+
3156app . listen ( 8080 , ( ) => {
3257 console . log ( `Server is listening...` ) ;
3358} ) ;
0 commit comments