This repository was archived by the owner on Mar 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.frm
498 lines (433 loc) · 17.2 KB
/
Form1.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3525
ClientLeft = 120
ClientTop = 465
ClientWidth = 5070
LinkTopic = "Form1"
ScaleHeight = 3525
ScaleWidth = 5070
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton SenderIds
Caption = "발신번호 조회"
Height = 495
Index = 0
Left = 3360
TabIndex = 9
Top = 2640
Width = 1215
End
Begin VB.CommandButton UnitPrice
Caption = "단가조회"
Height = 495
Index = 1
Left = 3360
TabIndex = 8
Top = 2040
Width = 1215
End
Begin VB.CommandButton Chingutalk
Caption = "친구톡 발송"
Height = 495
Index = 1
Left = 1920
TabIndex = 7
Top = 1440
Width = 1215
End
Begin VB.CommandButton Alimtalk
Caption = "알림톡 발송"
Height = 495
Index = 0
Left = 1920
TabIndex = 6
Top = 840
Width = 1215
End
Begin VB.CommandButton MMS
Caption = "MMS 발송"
Height = 495
Index = 1
Left = 480
TabIndex = 5
Top = 2040
Width = 1215
End
Begin VB.CommandButton Balance
Caption = "잔액조회"
Height = 495
Index = 1
Left = 3360
TabIndex = 4
Top = 840
Width = 1215
End
Begin VB.CommandButton LMS
Caption = "LMS 발송"
Height = 495
Index = 0
Left = 480
TabIndex = 3
Top = 1440
Width = 1215
End
Begin VB.CommandButton MessageList
Caption = "목록조회"
Height = 495
Index = 0
Left = 3360
TabIndex = 1
Top = 1440
Width = 1215
End
Begin VB.CommandButton SMS
Caption = "SMS 발송"
Height = 495
Left = 480
TabIndex = 0
Top = 840
Width = 1215
End
Begin VB.Label Label1
Caption = "요청 결과가 디버그 창에 출력됩니다."
Height = 255
Left = 600
TabIndex = 2
Top = 240
Width = 3495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Alimtalk_Click(Index As Integer)
' 텍스트 내용만 있는 간단한 알림톡
Dim kakaoOptions1 As New Dictionary
kakaoOptions1.Add "pfId", "KA01PF190626020502205cl0mYSoplA2" ' 카카오톡채널 연동 후 발급받은 값을 사용해 주세요
kakaoOptions1.Add "templateId", "KA01TP190626032036196g86q1RGN7D1" ' 템플릿 등록 후 발급받은 값을 사용해 주세요
Dim msg1 As New Dictionary
msg1.Add "to", "01000000001"
msg1.Add "from", "029302266"
msg1.Add "text", "안녕하세요." & vbLf & "홍길동님 회원가입을 환영합니다."
msg1.Add "kakaoOptions", kakaoOptions1
' 웹 링크 버튼이 하나 있는 알림톡
Dim button1 As New Dictionary
button1.Add "buttonName", "시작하기"
button1.Add "buttonType", "WL"
button1.Add "linkMo", "https://example.com"
Dim kakaoOptions2 As New Dictionary
kakaoOptions2.Add "pfId", "KA01PF190626020502205cl0mYSoplA2"
kakaoOptions2.Add "templateId", "KA01TP190626032036196g86q1RGN7D2"
kakaoOptions2.Add "buttons", Array(button1)
Dim msg2 As New Dictionary
msg2.Add "to", "01000000002"
msg2.Add "from", "029302266"
msg2.Add "text", "안녕하세요." & vbLf & "홍길동님 회원가입을 환영합니다."
msg2.Add "kakaoOptions", kakaoOptions2
' 모든 종류의 버튼 예시
Dim button2 As New Dictionary
button2.Add "buttonName", "시작하기"
button2.Add "buttonType", "WL"
button2.Add "linkMo", "https://m.example.com"
button2.Add "linkPc", "https://example.com"
Dim button3 As New Dictionary
button3.Add "buttonName", "앱실행"
button3.Add "buttonType", "AL"
button3.Add "linkAnd", "examplescheme://" ' 안드로이드
button3.Add "linkIos", "examplescheme://" ' iOS
Dim button4 As New Dictionary
button4.Add "buttonName", "배송조회"
button4.Add "buttonType", "DS"
Dim button5 As New Dictionary
button5.Add "buttonName", "봇키워드"
button5.Add "buttonType", "BK" ' 챗봇에게 키워드를 전달합니다. 버튼이름의 키워드가 그대로 전달됩니다.
Dim button6 As New Dictionary
button6.Add "buttonName", "상담요청하기"
button6.Add "buttonType", "MD" ' 상담요청하기 버튼을 누르면 수신 받은 알림톡 메시지가 상담원에게 그대로 전달됩니다.
Dim kakaoOptions3 As New Dictionary
kakaoOptions3.Add "pfId", "KA01PF190626020502205cl0mYSoplA2"
kakaoOptions3.Add "templateId", "KA01TP190626032036196g86q1RGN7D3"
kakaoOptions3.Add "buttons", Array(button2, button3, button4, button5, button6)
Dim msg3 As New Dictionary
msg3.Add "to", "01000000003"
msg3.Add "from", "029302266"
msg3.Add "text", "안녕하세요." & vbLf & "홍길동님 회원가입을 환영합니다." & vbLf & "아래 다양한 형식의 버튼을 통해 사용방법을 익히실 수 있습니다."
msg3.Add "kakaoOptions", kakaoOptions3
' 1만건까지 추가 가능
Dim Messages
Messages = Array(msg1, msg2, msg3)
Dim Body As New Dictionary
Body.Add "messages", Messages
Dim Response As WebResponse
Set Response = Request("messages/v4/send-many", "POST", Body)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print ("발송성공")
' JSON Object로 접근
Debug.Print ("Group ID:" & Response.data("groupId"))
Debug.Print ("Status:" & Response.data("status"))
Debug.Print ("Total Count:" & Response.data("count")("total"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
Else
Debug.Print ("발송실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub Balance_Click(Index As Integer)
Dim Response As WebResponse
Set Response = Request("cash/v1/balance", "GET")
If Response.StatusCode = WebStatusCode.Ok Then
' JSON Object로 접근
Debug.Print ("현재 잔액:" & Response.data("balance"))
Debug.Print ("현재 포인트:" & Response.data("point"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
MsgBox ("현재 잔액은 " & Response.data("balance") & "원 그리고 " & Response.data("point") & "포인트가 남아있습니다.")
Else
Debug.Print ("잔액조회실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub Chingutalk_Click(Index As Integer)
' 텍스트 내용만 있는 간단한 친구톡
Dim kakaoOptions1 As New Dictionary
kakaoOptions1.Add "pfId", "KA01PF190626020502205cl0mYSoplA2" ' 카카오톡채널 연동 후 발급받은 값을 사용해 주세요
Dim msg1 As New Dictionary
msg1.Add "to", "01000000001"
msg1.Add "from", "029302266"
msg1.Add "text", "광고를 포함하여 어떤 내용이든 입력 가능합니다."
msg1.Add "kakaoOptions", kakaoOptions1
' 모든 종류의 버튼 예시
Dim button1 As New Dictionary
button1.Add "buttonName", "시작하기"
button1.Add "buttonType", "WL"
button1.Add "linkMo", "https://m.example.com" ' 모바일 기기에서 보여지는 링크
button1.Add "linkPc", "https://example.com" ' PC에서 보여지는 링크
Dim button2 As New Dictionary
button2.Add "buttonName", "앱실행"
button2.Add "buttonType", "AL"
button2.Add "linkAnd", "https://example.com" ' 안드로이드
button2.Add "linkIos", "https://example.com" ' iOS
Dim button3 As New Dictionary
button3.Add "buttonName", "봇키워드"
button3.Add "buttonType", "BK" ' 챗봇에게 키워드를 전달합니다. 버튼이름의 키워드가 그대로 전달됩니다.
Dim button4 As New Dictionary
button4.Add "buttonName", "상담요청하기"
button4.Add "buttonType", "MD" ' 상담요청하기 버튼을 누르면 수신 받은 알림톡 메시지가 상담원에게 그대로 전달됩니다.
Dim kakaoOptions2 As New Dictionary
kakaoOptions2.Add "pfId", "KA01PF190626020502205cl0mYSoplA2"
kakaoOptions2.Add "buttons", Array(button1, button2, button3, button4)
Dim msg2 As New Dictionary
msg2.Add "to", "01000000002"
msg2.Add "from", "029302266"
msg2.Add "text", "광고를 포함하여 어떤 내용이든 입력 가능합니다."
msg2.Add "kakaoOptions", kakaoOptions2
' 친구톡에 사용할 이미지 업로드
Dim resp As WebResponse
Dim imageId As String
Set resp = UploadKakaoImage("testImage.jpg", "https://example.com")
If resp.StatusCode <> 200 Then
Debug.Print ("이미지 업로드 실패")
Exit Sub
End If
Debug.Print (resp.Content)
imageId = resp.data("fileId")
' 친구톡 이미지 발송
Dim kakaoOptions3 As New Dictionary
kakaoOptions3.Add "pfId", "KA01PF190626020502205cl0mYSoplA2"
kakaoOptions3.Add "imageId", imageId
Dim msg3 As New Dictionary
msg3.Add "to", "01000000003"
msg3.Add "from", "029302266"
msg3.Add "text", "광고를 포함하여 어떤 내용이든 입력 가능합니다." & vbLf & "이미지를 터치하면 URL로 이동됩니다."
msg3.Add "kakaoOptions", kakaoOptions3
' 1만건까지 추가 가능
Dim Messages
Messages = Array(msg1, msg2, msg3)
Dim Body As New Dictionary
Body.Add "messages", Messages
Dim Response As WebResponse
Set Response = Request("messages/v4/send-many", "POST", Body)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print ("발송성공")
' JSON Object로 접근
Debug.Print ("Group ID:" & Response.data("groupId"))
Debug.Print ("Status:" & Response.data("status"))
Debug.Print ("Total Count:" & Response.data("count")("total"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
Else
Debug.Print ("발송실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub MessageList_Click(Index As Integer)
Dim Response As WebResponse
Set Response = Request("messages/v4/list", "GET")
Debug.Print (Response.StatusDescription)
Dim line As Integer
Dim indent As Integer
Debug.Print (Response.Content)
End Sub
Private Sub SenderIds_Click(Index As Integer)
Dim Response As WebResponse
Set Response = Request("senderid/v1/numbers/active", "GET")
If Response.StatusCode = WebStatusCode.Ok Then
' JSON Object로 접근
Dim senderIds As String
For i = 1 To Response.data.Count
Debug.Print ("발신번호:" & Response.data(i))
senderIds = senderIds & Response.data(i)
If i <> Response.data.Count Then
senderIds = senderIds & ", "
End If
Next
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
MsgBox ("발신번호 목록: " & senderIds)
Else
Debug.Print ("발신번호조회 실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub SMS_Click()
Dim msg1 As New Dictionary
msg1.Add "to", "01000000001"
msg1.Add "from", "029302266"
msg1.Add "text", "한글 45자, 영자 90자 이하 입력되면 자동으로 SMS타입의 메시지가 추가됩니다."
Dim msg2 As New Dictionary
msg2.Add "to", "01000000002"
msg2.Add "from", "029302266"
msg2.Add "text", "한글 45자, 영자 90자 이상 입력되면 자동으로 LMS타입의 문자메시자가 발송됩니다. 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
' 타입을 명시할 경우 text 길이가 한글 45 혹은 영자 90자를 넘을 경우 오류가 발생합니다.
Dim msg3 As New Dictionary
msg3.Add "type", "SMS" ' 타입을 SMS로 입력
msg3.Add "to", "01000000003"
msg3.Add "from", "029302266"
msg3.Add "text", "SMS 타입에 한글 45자, 영자 90자 이상 입력되면 오류가 발생합니다. 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
' 1만건까지 추가 가능
Dim Messages
Messages = Array(msg1, msg2, msg3)
Dim Body As New Dictionary
Body.Add "messages", Messages
Dim Response As WebResponse
Set Response = Request("messages/v4/send-many", "POST", Body)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print ("발송성공")
' JSON Object로 접근
Debug.Print ("Group ID:" & Response.data("groupId"))
Debug.Print ("Status:" & Response.data("status"))
Debug.Print ("Total Count:" & Response.data("count")("total"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
Else
Debug.Print ("발송실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub LMS_Click(Index As Integer)
Dim msg1 As New Dictionary
msg1.Add "to", "01000000001"
msg1.Add "from", "029302266"
msg1.Add "text", "한글 45자, 영자 90자 이상 입력되면 자동으로 LMS타입의 문자메시자가 발송됩니다. 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim msg2 As New Dictionary
msg2.Add "to", "01000000002"
msg2.Add "from", "029302266"
msg2.Add "subject", "LMS 제목" ' 제목을 지정할 수 있습니다.
msg2.Add "text", "한글 45자, 영자 90자 이상 입력되면 자동으로 LMS타입의 문자메시자가 발송됩니다. 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim msg3 As New Dictionary
msg3.Add "type", "LMS" ' 타입을 명시할 수 있습니다.
msg3.Add "to", "01000000003"
msg3.Add "from", "029302266"
msg3.Add "text", "내용이 짧아도 LMS로 발송됩니다."
Dim msg4 As New Dictionary
msg4.Add "to", "01000000004"
msg4.Add "from", "029302266"
msg4.Add "text", "한글 45자, 영자 90자 이하는 자동으로 SMS타입의 문자가 발송됩니다."
' 1만건까지 추가 가능
Dim Messages
Messages = Array(msg1, msg2, msg3, msg4)
Dim Body As New Dictionary
Body.Add "messages", Messages
Dim Response As WebResponse
Set Response = Request("messages/v4/send-many", "POST", Body)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print ("발송성공")
' JSON Object로 접근
Debug.Print ("Group ID:" & Response.data("groupId"))
Debug.Print ("Status:" & Response.data("status"))
Debug.Print ("Total Count:" & Response.data("count")("total"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
Else
Debug.Print ("발송실패")
Debug.Print (Response.Content)
End If
End Sub
Private Sub MMS_Click(Index As Integer)
On Error GoTo Handler
Dim resp As WebResponse
Dim imageId As String
Set resp = UploadImage("testImage.jpg")
If resp.StatusCode <> 200 Then
Exit Sub
End If
Debug.Print (resp.Content)
imageId = resp.data("fileId")
Dim msg1 As New Dictionary
msg1.Add "to", "01000000001"
msg1.Add "from", "029302266"
msg1.Add "subject", "MMS 제목"
msg1.Add "text", "이미지 아이디가 입력되면 MMS로 발송됩니다."
msg1.Add "imageId", imageId
Dim msg2 As New Dictionary
msg2.Add "to", "01000000002"
msg2.Add "from", "029302266"
msg2.Add "subject", "MMS 제목"
msg2.Add "text", "동일한 이미지 아이디가 입력되면 동일한 이미지가 MMS로 발송됩니다."
msg2.Add "imageId", imageId
' 1만건까지 추가 가능
Dim Messages
Messages = Array(msg1, msg2)
Dim Body As New Dictionary
Body.Add "messages", Messages
Dim Response As WebResponse
Set Response = Request("messages/v4/send-many", "POST", Body)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print ("발송성공")
' JSON Object로 접근
Debug.Print ("Group ID:" & Response.data("groupId"))
Debug.Print ("Status:" & Response.data("status"))
Debug.Print ("Total Count:" & Response.data("count")("total"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
Else
Debug.Print ("발송실패")
Debug.Print (Response.Content)
End If
Handler:
Debug.Print "Error " & Err.Number & Err.Source & Err.Description
End Sub
Private Sub UnitPrice_Click(Index As Integer)
Dim Response As WebResponse
Set Response = Request("pricing/v1/messaging", "GET")
If Response.StatusCode = WebStatusCode.Ok Then
' JSON Object로 접근
Debug.Print ("SMS 단가:" & Response.data("sms"))
Debug.Print ("LMS 단가:" & Response.data("lms"))
Debug.Print ("MMS 단가:" & Response.data("mms"))
Debug.Print ("알림톡 단가:" & Response.data("ata"))
Debug.Print ("친구톡 단가:" & Response.data("cta"))
Debug.Print ("친구톡 이미지 단가:" & Response.data("cti"))
Debug.Print ("네이버스마트알림 단가:" & Response.data("nsa"))
' String 형식으로 접근 모든 내용 출력
Debug.Print (Response.Content)
MsgBox ("단가 안내" & vbCrLf & "SMS:" & Response.data("sms") & vbCrLf & "LMS:" & Response.data("lms") & vbCrLf & "MMS:" & Response.data("mms") & vbCrLf & "알림톡:" & Response.data("ata") & vbCrLf & "친구톡:" & Response.data("cta") & vbCrLf & "친구톡(이미지):" & Response.data("cti") & vbCrLf & "네이버스마트알림:" & Response.data("nsa"))
Else
Debug.Print ("단가조회 실패")
Debug.Print (Response.Content)
End If
End Sub