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 라이선스를 따릅니다.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_solapi_messages-0.1.6.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_solapi_messages-0.1.6-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file python_solapi_messages-0.1.6.tar.gz.

File metadata

  • Download URL: python_solapi_messages-0.1.6.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for python_solapi_messages-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ed474ea2026067d8870c5a803bda7f0c94640b3703423bf6eeb8f2bbabb119d4
MD5 afbf09a9bcd5eab1d04260bb81bc601d
BLAKE2b-256 552b9cddb8639d753c670bbdab4865f44cd8497453da781cb93042f149ff4482

See more details on using hashes here.

File details

Details for the file python_solapi_messages-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for python_solapi_messages-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6a39482abb29307573675603c0dea0c17822f08ca66794f682237a3ce50aef55
MD5 60db081682edbcef92ccbe5d0e6b026d
BLAKE2b-256 6cb081fe8f8b7e4b1faa23566a9b55459d98b4b6b0a75a4f7ffe27140746a7f0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page