|
1 | 1 | /** |
2 | 2 | * 메시지 조회 예제(문자, 알림톡 등) |
3 | 3 | */ |
4 | | -const { SolapiMessageService } = require("solapi"); |
5 | | -const messageService = new SolapiMessageService("ENTER_YOUR_API_KEY", "ENTER_YOUR_API_SECRET"); |
6 | | - |
7 | | -messageService.getMessages({ |
8 | | - // 불러올 메시지 갯수 제한 |
9 | | - // limit: 5, // 5를 입력하면 5건이 조회됩니다, 미 입력시 20개로 지정 |
10 | | - |
11 | | - // 메시지 ID로 검색 |
12 | | - // messageId: '메시지 ID 입력', // 메시지 ID는 대개 M4V로 시작합니다 |
13 | | - |
14 | | - // 여러 메시지 ID로 검색 |
15 | | - /*messageIds: [ |
| 4 | +const {SolapiMessageService} = require('solapi'); |
| 5 | +const messageService = new SolapiMessageService( |
| 6 | + 'ENTER_YOUR_API_KEY', |
| 7 | + 'ENTER_YOUR_API_SECRET', |
| 8 | +); |
| 9 | + |
| 10 | +messageService |
| 11 | + .getMessages({ |
| 12 | + // 불러올 메시지 갯수 제한 |
| 13 | + // limit: 5, // 5를 입력하면 5건이 조회됩니다, 미 입력시 20개로 지정 |
| 14 | + // 메시지 ID로 검색 |
| 15 | + // messageId: '메시지 ID 입력', // 메시지 ID는 대개 M4V로 시작합니다 |
| 16 | + // 여러 메시지 ID로 검색 |
| 17 | + /*messageIds: [ |
16 | 18 | '메시지 ID 입력' // 메시지 ID는 대개 M4V로 시작합니다 |
17 | 19 | ],*/ |
18 | | - |
19 | | - // 그룹 ID로 검색 |
20 | | - // groupId: '그룹 ID 입력', // 그룹 ID는 대개 G4V로 시작합니다 |
21 | | - |
22 | | - // 발신번호로 검색 |
23 | | - // from: '01012345678', |
24 | | - |
25 | | - // 수신번호로 검색 |
26 | | - // to: '01012345678', |
27 | | - |
28 | | - /** |
29 | | - * 메시지 타입으로 검색 |
30 | | - * SMS: 단문 문자, LMS: 장문 문자, MMS: 사진 문자, ATA: 알림톡, CTA: 친구톡, CTI: 이미지(1장) 친구톡 |
31 | | - */ |
32 | | - // type: "SMS", |
33 | | - |
34 | | - // 날짜로 검색하는 경우 |
35 | | - /*duration: { |
36 | | - dateType: 'CREATED', 메시지 생성 일 기준, UPDATED로 변경하면 메시지 상태 갱신일자 기준으로 조회 함 |
37 | | - startDate: '2022-03-01 00:00:00', // Date 객체로도 요청 가능 |
38 | | - endDate: '2022-03-31 23:59:59' // Date 객체로도 요청 가능 |
39 | | - }*/ |
40 | | -}).then(res => console.log(res)); |
| 20 | + // 그룹 ID로 검색 |
| 21 | + // groupId: '그룹 ID 입력', // 그룹 ID는 대개 G4V로 시작합니다 |
| 22 | + // 발신번호로 검색 |
| 23 | + // from: '01012345678', |
| 24 | + // 수신번호로 검색 |
| 25 | + // to: '01012345678', |
| 26 | + /** |
| 27 | + * 메시지 타입으로 검색 |
| 28 | + * SMS: 단문 문자, LMS: 장문 문자, MMS: 사진 문자, ATA: 알림톡, CTA: 친구톡, CTI: 이미지(1장) 친구톡 |
| 29 | + */ |
| 30 | + // type: "SMS", |
| 31 | + // 날짜로 검색하는 경우 |
| 32 | + // startDate: '2022-12-01 00:00:00', // Date 객체로도 요청 가능 |
| 33 | + // endDate: '2022-12-31 23:59:59', // Date 객체로도 요청 가능 |
| 34 | + }) |
| 35 | + .then(res => console.log(res)); |
41 | 36 |
|
42 | 37 | /** |
43 | 38 | * 페이징 예제 |
44 | 39 | * */ |
45 | 40 | messageService.getMessages().then(res => { |
46 | | - |
47 | | - messageService.getMessages({ |
48 | | - // startKey 부분에 nextKey를 입력할 경우 초기 20건 다음의 데이터를 표시하게 됩니다. |
49 | | - startKey: res.nextKey |
50 | | - }).then(res2 => { |
51 | | - console.log(res2); |
52 | | - }); |
53 | | - |
| 41 | + messageService |
| 42 | + .getMessages({ |
| 43 | + // startKey 부분에 nextKey를 입력할 경우 초기 20건 다음의 데이터를 표시하게 됩니다. |
| 44 | + startKey: res.nextKey, |
| 45 | + }) |
| 46 | + .then(res2 => { |
| 47 | + console.log(res2); |
| 48 | + }); |
54 | 49 | }); |
0 commit comments