Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 8aab5a0

Browse files
committed
Merge pull request #5 from wileyday/master
코드 정리
2 parents f830435 + 43d71f6 commit 8aab5a0

15 files changed

Lines changed: 244 additions & 227 deletions

coolsms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import json
88
import time
99
import platform
10-
if sys.version_info.major == 2:
10+
11+
# sys.version_info.major is available in python version 2.7
12+
# use sys.version_info[0] for python 2.6
13+
if sys.version_info[0] == 2:
1114
from httplib import HTTPSConnection
1215
from urllib import urlencode
1316
else:
@@ -160,7 +163,7 @@ def send(self, to=None, text=None, sender=None, mtype=None, subject=None, image=
160163
A JSON type string will be returned. On failure, False will be returned.
161164
"""
162165
# convert list to a comma seperated string
163-
if sys.version_info.major == 2:
166+
if sys.version_info[0] == 2:
164167
t_temp = text.decode('utf-8')
165168
text = t_temp.encode('utf-8')
166169
text = unicode(text, encoding='utf-8')

coolsms.pyc

-9.61 KB
Binary file not shown.

examples/balance.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2014 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
api_key = 'NCS52A57F48C3D32'
12-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13-
cool = coolsms.rest(api_key, api_secret)
14-
cash, point = cool.balance()
15-
print "cash : %u, point : %u" % (cash, point)
12+
api_key = 'NCS52A57F48C3D32'
13+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
14+
cool = coolsms.rest(api_key, api_secret)
15+
cash, point = cool.balance()
16+
print "cash : %u, point : %u" % (cash, point)
1617

1718
if __name__ == "__main__":
18-
main()
19-
sys.exit(0)
19+
main()
20+
sys.exit(0)

examples/cancel_reservation.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2014 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
api_key = 'NCS52A57F48C3D32'
12-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13-
cool = coolsms.rest(api_key, api_secret)
14-
status = cool.cancel(mid='R1M52D35EAF44960')
15-
print status
12+
api_key = 'NCS52A57F48C3D32'
13+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
14+
cool = coolsms.rest(api_key, api_secret)
15+
status = cool.cancel(mid='R1M52D35EAF44960')
16+
print status
1617

1718
if __name__ == "__main__":
18-
main()
19-
sys.exit(0)
19+
main()
20+
sys.exit(0)

examples/get_status_by_mid.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2014 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
api_key = 'NCS52A57F48C3D32'
12-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13-
cool = coolsms.rest(api_key, api_secret)
14-
status = cool.status(mid='R2M5301BF9F6113C')
15-
print status
12+
api_key = 'NCS52A57F48C3D32'
13+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
14+
cool = coolsms.rest(api_key, api_secret)
15+
status = cool.status(mid='R2M5301BF9F6113C')
16+
print status
1617

1718
if __name__ == "__main__":
18-
main()
19-
sys.exit(0)
19+
main()
20+
sys.exit(0)

examples/line_status.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2014 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
api_key = 'NCS52A57F48C3D32'
12-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13-
cool = coolsms.rest(api_key, api_secret)
14-
status = cool.line_status()
15-
print status
12+
api_key = 'NCS52A57F48C3D32'
13+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
14+
cool = coolsms.rest(api_key, api_secret)
15+
status = cool.line_status()
16+
print status
1617

1718
if __name__ == "__main__":
18-
main()
19-
sys.exit(0)
19+
main()
20+
sys.exit(0)

examples/send_extensions.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2015 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
6-
import sys,json
7+
import sys
8+
import json
79
sys.path.append("..")
810
import coolsms
911

1012
def main():
11-
# API Credential 정보
12-
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
13-
api_key = 'NCS52A57F48C3D32'
14-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13+
# API Credential 정보
14+
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
15+
api_key = 'NCS52A57F48C3D32'
16+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
1517

16-
# 수신번호
17-
to = '01000000000,01011111111' # <--- input comma-separated numbers
18+
# 수신번호
19+
to = '01000000000,01011111111' # <--- input comma-separated numbers
1820

19-
# 발신번호
20-
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
21-
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
22-
sender = '01012345678'
21+
# 발신번호
22+
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
23+
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
24+
sender = '01012345678'
2325

24-
# 메시지 내용
25-
message = '테스트 메시지'
26+
# 메시지 내용
27+
message = '테스트 메시지'
2628

27-
# JSON형식의 extension 데이터
28-
# 위에서 정의된 to, sender, message 등 기본 데이터를 상속받아 개별 메시지로 발송된다.
29-
data = [ {"to":"01000000001", "text":"Hello A"}, {"to":"01000000002", "text":"Hello B"} ]
30-
extension = json.dumps(data)
29+
# JSON형식의 extension 데이터
30+
# 위에서 정의된 to, sender, message 등 기본 데이터를 상속받아 개별 메시지로 발송된다.
31+
data = [ {"to":"01000000001", "text":"Hello A"}, {"to":"01000000002", "text":"Hello B"} ]
32+
extension = json.dumps(data)
3133

32-
# API Key, API Secret, App Version
33-
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
34-
status = cool.send(to,message,sender,extension=extension)
34+
# API Key, API Secret, App Version
35+
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
36+
status = cool.send(to,message,sender,extension=extension)
3537

36-
# 리턴값 출력
37-
print status
38+
# 리턴값 출력
39+
print status
3840

39-
# 리턴값이 False이면 오류
40-
if status == False:
41-
print "ERROR: %s" % cool.get_error()
41+
# 리턴값이 False이면 오류
42+
if status == False:
43+
print "ERROR: %s" % cool.get_error()
4244

4345
if __name__ == "__main__":
44-
main()
45-
sys.exit(0)
46+
main()
47+
sys.exit(0)

examples/send_lms.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2015 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
# API Credential 정보
12-
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
13-
api_key = 'NCS52A57F48C3D32'
14-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
12+
# API Credential 정보
13+
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
14+
api_key = 'NCS52A57F48C3D32'
15+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
1516

16-
# 수신번호
17-
to = '01000000000'
17+
# 수신번호
18+
to = '01000000000'
1819

19-
# 발신번호
20-
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
21-
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
22-
sender = '01012345678'
20+
# 발신번호
21+
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
22+
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
23+
sender = '01012345678'
2324

24-
# 메시지 내용
25-
message = 'LMS 2,000 바이트까지 입력가능합니다'
25+
# 메시지 내용
26+
message = 'LMS 2,000 바이트까지 입력가능합니다'
2627

27-
# API Key, API Secret, App Version
28-
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
28+
# API Key, API Secret, App Version
29+
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
2930

30-
# 메시지 발송 요청
31-
status = cool.send(to,message,sender,mtype='lms',subject='LMS 제목(40바이트)')
31+
# 메시지 발송 요청
32+
status = cool.send(to,message,sender,mtype='lms',subject='LMS 제목(40바이트)')
3233

33-
# 리턴값 출력
34-
print status
34+
# 리턴값 출력
35+
print status
3536

36-
# 리턴값이 False이면 오류
37-
if status == False:
38-
print cool.get_error()
37+
# 리턴값이 False이면 오류
38+
if status == False:
39+
print cool.get_error()
3940

4041
if __name__ == "__main__":
41-
main()
42-
sys.exit(0)
42+
main()
43+
sys.exit(0)

examples/send_mms.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2015 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
# API Credential 정보
12-
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
13-
api_key = 'NCS52A57F48C3D32'
14-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
12+
# API Credential 정보
13+
# https://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigCredentials
14+
api_key = 'NCS52A57F48C3D32'
15+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
1516

16-
# 수신번호
17-
to = '01000000000'
17+
# 수신번호
18+
to = '01000000000'
1819

19-
# 발신번호
20-
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
21-
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
22-
sender = '01012345678'
20+
# 발신번호
21+
# 2015/10/16 발신번호 등록제 시행에 따라 사전에 등록된 발신번호만 허용
22+
# http://www.coolsms.co.kr/index.php?mid=service_setup&act=dispSmsconfigSenderNumbers
23+
sender = '01012345678'
2324

24-
# 메시지 내용
25-
message = 'MMS 2,000 바이트까지 입력가능합니다'
25+
# 메시지 내용
26+
message = 'MMS 2,000 바이트까지 입력가능합니다'
2627

27-
# API Key, API Secret, App Version
28-
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
28+
# API Key, API Secret, App Version
29+
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
2930

30-
# 메시지 발송 요청
31-
status = cool.send(to,message,sender,mtype='mms',subject='MMS 제목(40바이트)',image='test.jpg')
31+
# 메시지 발송 요청
32+
status = cool.send(to,message,sender,mtype='mms',subject='MMS 제목(40바이트)',image='test.jpg')
3233

33-
# 리턴값 출력
34-
print status
34+
# 리턴값 출력
35+
print status
3536

36-
# 리턴값이 False이면 오류
37-
if status == False:
38-
print cool.get_error()
37+
# 리턴값이 False이면 오류
38+
if status == False:
39+
print cool.get_error()
3940

4041
if __name__ == "__main__":
41-
main()
42-
sys.exit(0)
42+
main()
43+
sys.exit(0)

examples/send_oversea_sms.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
# -*- coding: utf8 -*-
2+
# vi:set sw=4 ts=4 expandtab:
23
"""
3-
Copyright (C) 2008-2015 NURIGO
4+
Copyright (C) 2008-2016 NURIGO
45
http://www.coolsms.co.kr
56
"""
67
import sys
78
sys.path.append("..")
89
import coolsms
910

1011
def main():
11-
api_key = 'NCS52A57F48C3D32'
12-
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
13-
to = '01000000000'
14-
sender = '01012345678'
15-
message = '테스트 메시지'
16-
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
17-
status = cool.send(to,message,sender,country='81') # <---- 국가번호 입력
18-
print status
19-
if status == False:
20-
print "ERROR: %s" % cool.get_error()
12+
api_key = 'NCS52A57F48C3D32'
13+
api_secret = '5AC44E03CE8E7212D9D1AD9091FA9966'
14+
to = '01000000000'
15+
sender = '01012345678'
16+
message = '테스트 메시지'
17+
cool = coolsms.rest(api_key, api_secret, 'Example 1.0')
18+
status = cool.send(to,message,sender,country='81') # <---- 국가번호 입력
19+
print status
20+
if status == False:
21+
print "ERROR: %s" % cool.get_error()
2122

2223
if __name__ == "__main__":
23-
main()
24-
sys.exit(0)
24+
main()
25+
sys.exit(0)

0 commit comments

Comments
 (0)