-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_sms.exs
More file actions
36 lines (28 loc) · 1 KB
/
send_sms.exs
File metadata and controls
36 lines (28 loc) · 1 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
#!/usr/bin/env elixir
# SMS 발송 예제
# 실행: elixir examples/send_sms.exs
Mix.install([
{:solapi, path: Path.join(__DIR__, "..")}
])
# 환경변수에서 API 키 읽기
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)
# SMS 발송 (90바이트 이하)
message = %{
# 수신번호 (실제 번호로 변경)
to: "01012345678",
# 발신번호 (SOLAPI에서 사전 등록 필요)
from: "0212345678",
text: "안녕하세요! SOLAPI SDK 테스트 메시지입니다."
}
IO.puts("SMS 발송 중...")
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