Skip to main content

SolApi Messages Python Library

SolApi Messages는 SolApi 서비스를 사용하여 문자메시지와 카카오 알림톡을 쉽게 전송할 수 있게 해주는 Python 라이브러리입니다.

주요 기능

  • SMS, LMS, MMS 메시지 전송
  • 단일 및 대량 메시지 전송
  • 예약 발송
  • 메시지 길이에 따른 자동 유형 전환
  • 이미지 파일이 존재할 경우 MMS로 자동 전환
  • 카카오 알림톡 전송

설치

pip를 사용하여 라이브러리를 설치할 수 있습니다.

pip install python-solapi-messages

사용법

환경설정

SolAPI에서 발급받은 키를 사용해 설정을 초기화해주세요.

from solapi.config import SolApiConfig

config = SolApiConfig(api_key="YOUR_API_KEY", secret_key="YOUR_SECRET_KEY")

SMS 전송

from solapi.sms.sms import SMS
from solapi.senders.message_senders import MessageSender

sender = MessageSender(config)
message = SMS(from_number="01012345678", text="Hello, World!")
result = sender.send_one(message, to_number="01087654321")
print(result)

LMS 전송

from solapi.sms.lms import LMS

message = LMS(from_number="01012345678", text="긴 메시지 내용", subject="제목")
result = sender.send_one(message, to_number="01087654321")
print(result)

MMS 전송

from solapi.sms.mms import MMS

message = MMS(from_number="01012345678", text="MMS 메시지", subject="MMS 제목", file_id="FILE_ID")
result = sender.send_one(message, to_number="01087654321")
print(result)

알림톡 전송

from solapi.kakao_talk.alim_talk import AlimTalkOptions, AlimTalkMessage

options = AlimTalkOptions(pf_id="PFID", template_id="TEMPLATE_ID", variables={"VAR1": "값1"})
message = AlimTalkMessage(from_number="01012345678", alimtalk_options=options)
result = sender.send_one(message, to_number="01087654321")
print(result)

대량 발송

send_many 메소드를 사용하면 여러 수신자에게 동일한 메시지를 보낼 수 있습니다.

to_numbers = ["01087654321", "01098765432", "01076543210"]
result = sender.send_many(message, to_numbers)
print(result)

예약 발송

scheduled_date 파라미터를 사용하면 원하는 발송 시간을 정할 수 있습니다.

import datetime

scheduled_time = datetime.datetime.now() + datetime.timedelta(hours=1)  # 1시간 후 발송
message = SMS(from_number="01012345678", text="예약된 메시지입니다.", scheduled_date=scheduled_time)
result = sender.send_one(message, to_number="01087654321")
print(result)

이미지 업로드

이미지를 먼저 업로드해야 fileId를 얻을 수 있습니다.

import datetime

from solapi.storage import upload_image

response = upload_image("path/to/image.jpg", config)
file_id = response.json()['fileId']

테스트

아래 코드를 입력하시면 테스트를 실행할 수 있습니다.

python -m unittest discover tests

라이선스

이 프로젝트는 MIT 라이선스를 따릅니다.

Metadata

Release files for python-solapi-messages 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-solapi-messages 0.1.6
File Size Uploaded
python_solapi_messages-0.1.6.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-solapi-messages 0.1.6
File Interpreter ABI Platform
python_solapi_messages-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / python_solapi_messages-0.1.6.tar.gz

Download URL python_solapi_messages-0.1.6.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ed474ea2026067d8870c5a803bda7f0c94640b3703423bf6eeb8f2bbabb119d4
BLAKE2b-256 checksum
How to use checksums
552b9cddb8639d753c670bbdab4865f44cd8497453da781cb93042f149ff4482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / python_solapi_messages-0.1.6-py3-none-any.whl

Download URL python_solapi_messages-0.1.6-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a39482abb29307573675603c0dea0c17822f08ca66794f682237a3ce50aef55
BLAKE2b-256 checksum
How to use checksums
6cb081fe8f8b7e4b1faa23566a9b55459d98b4b6b0a75a4f7ffe27140746a7f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page