Skip to content

Commit 37858df

Browse files
committed
단건 발송 및 해외 발송 예제 추가
1 parent 5d7e913 commit 37858df

7 files changed

Lines changed: 121 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
44

55
## 사용 준비
6-
- [ ] [config.ini](https://github.com/solapi/examples/blob/python/python/config.ini)에 정보 입력
6+
- [ ] [config.ini]
77
- [ ] ApiKey
88
- [ ] ApiSecret
99
- [ ] to (수신번호)

group/add_group_message.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# [INPUT_GROUP_ID] 에 그룹 아이디를 넣어주세요
1414
# ex) G4V20181005122748TESTTESTTESTTES
1515
data = {
16-
'messages': json.dumps([
16+
'messages': [
1717
{
1818
'to': '수신번호 입력',
1919
'from': '발신번호 입력',
@@ -23,10 +23,17 @@
2323
'to': '수신번호2 입력',
2424
'from': '발신번호2 입력',
2525
'text': '예제 메시지2'
26+
},
27+
{
28+
# 해외 문자
29+
'country': '국가번호 입력',
30+
'to': '현지 수신번호',
31+
'from': '발신번호 입력',
32+
'text': 'Hello There'
2633
}
27-
])
34+
]
2835
}
29-
res = requests.put(config.getUrl('messages/v4/groups/[INPUT_GROUP_ID]/messages'),
36+
res = requests.put(config.getUrl('/messages/v4/groups/[INPUT_GROUP_ID]/messages'),
3037
headers=auth.get_headers(config.apiKey, config.apiSecret),
3138
json=data)
3239
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

simple/send_one_lms.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
import json
3+
import sys
4+
import os.path
5+
6+
sys.path.append('../')
7+
8+
from auth import auth
9+
import config
10+
11+
# LMS 단건 발송
12+
# 제목(subject)을 지정하지 않으면 메시지 내용(text) 앞 부분을 제목으로 사용합니다.
13+
if __name__ == '__main__':
14+
data = {
15+
'message': {
16+
'to': '수신번호 입력',
17+
'from': '발신번호 입력',
18+
'text': '한글 45자, 영자 90자 이상 입력되면 자동으로 LMS타입의 문자메시자가 발송됩니다. type 옵션을 주어 명시적으로 타입을 지정할 수도 있습니다.'
19+
}
20+
}
21+
res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
22+
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

simple/send_one_lms_subject.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
import json
3+
import sys
4+
import os.path
5+
6+
sys.path.append('../')
7+
8+
from auth import auth
9+
import config
10+
11+
# LMS 단건 발송
12+
# 제목(subject)을 지정하지 않으면 메시지 내용(text) 앞 부분을 제목으로 사용합니다.
13+
if __name__ == '__main__':
14+
data = {
15+
'message': {
16+
'to': '수신번호 입력',
17+
'from': '발신번호 입력',
18+
'subject': 'LMS 제목 입력',
19+
'text': '한글 45자, 영자 90자 이상 입력되면 자동으로 LMS타입의 문자메시자가 발송됩니다. type 옵션을 주어 명시적으로 타입을 지정할 수도 있습니다.'
20+
}
21+
}
22+
res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
23+
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

simple/send_one_oversea.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
import json
3+
import sys
4+
import os.path
5+
6+
sys.path.append('../')
7+
8+
from auth import auth
9+
import config
10+
11+
# 해외문자 단건 발송(2건 이상은 그룹메시지를 사용하세요)
12+
if __name__ == '__main__':
13+
data = {
14+
'message': {
15+
'country': '국가번호', # 국가번호를 입력하세요. 예) 미국(1), 중국(86), 일본(81)
16+
'to': '수신번호',
17+
'from': '발신번호',
18+
'text': 'Test Message'
19+
}
20+
}
21+
res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
22+
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

simple/send_one_sms.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import requests
2+
import json
3+
import sys
4+
import os.path
5+
6+
sys.path.append('../')
7+
8+
from auth import auth
9+
import config
10+
11+
# 문자 단건 발송
12+
if __name__ == '__main__':
13+
data = {
14+
'message': {
15+
'to': '수신번호 입력',
16+
'from': '발신번호 입력',
17+
'text': '테스트 메시지' # 한글 45자, 영어 90자 이상이면 LMS로 자동 발송
18+
}
19+
}
20+
res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
21+
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

simple/send_one_sms_explicit.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
import json
3+
import sys
4+
import os.path
5+
6+
sys.path.append('../')
7+
8+
from auth import auth
9+
import config
10+
11+
# type을 SMS로 지정한 경우 한글 45, 영어 90자를 넘으면 오류가 발생합니다.
12+
if __name__ == '__main__':
13+
data = {
14+
'message': {
15+
'type': 'SMS',
16+
'to': '수신번호 입력',
17+
'from': '발신번호 입력',
18+
'text': '테스트 메시지'
19+
}
20+
}
21+
res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
22+
print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))

0 commit comments

Comments
 (0)