-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_lms.exs
More file actions
48 lines (37 loc) · 1.32 KB
/
send_lms.exs
File metadata and controls
48 lines (37 loc) · 1.32 KB
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
#!/usr/bin/env elixir
# LMS (장문 메시지) 발송 예제
# 실행: elixir examples/send_lms.exs
Mix.install([
{:solapi, path: Path.join(__DIR__, "..")}
])
api_key = System.get_env("SOLAPI_API_KEY") || raise "SOLAPI_API_KEY 환경변수를 설정하세요"
api_secret = System.get_env("SOLAPI_API_SECRET") || raise "SOLAPI_API_SECRET 환경변수를 설정하세요"
client = Solapi.client(api_key: api_key, api_secret: api_secret)
# LMS 발송 (90바이트 초과 또는 type: "LMS" 지정)
message = %{
# 수신번호 (실제 번호로 변경)
to: "01012345678",
# 발신번호
from: "0212345678",
# 명시적으로 LMS 지정
type: "LMS",
# LMS는 제목 포함 가능
subject: "공지사항",
text: """
안녕하세요, SOLAPI SDK 테스트입니다.
장문 메시지(LMS)는 최대 2,000바이트까지 발송 가능합니다.
제목과 본문을 함께 전송할 수 있습니다.
- 90바이트 초과 시 자동으로 LMS로 전환됩니다.
- type: "LMS"로 명시적 지정도 가능합니다.
감사합니다.
"""
}
IO.puts("LMS 발송 중...")
case Solapi.send(client, message) do
{:ok, response} ->
IO.puts("발송 성공!")
IO.inspect(response, label: "응답", pretty: true)
{:error, error} ->
IO.puts("발송 실패!")
IO.inspect(error, label: "에러", pretty: true)
end