|
| 1 | +# Coolsms Python SDK |
| 2 | + |
| 3 | +Send Message & Message Management using Python and REST API. |
| 4 | + |
| 5 | +## Version |
| 6 | + |
| 7 | +v2.0 |
| 8 | + |
| 9 | +## License |
| 10 | + |
| 11 | +GPL v2 License |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +- Package install url ( source code & examples ) : http://www.coolsms.co.kr/download/545387 |
| 16 | + |
| 17 | +- Github : https://github.com/coolsms/python-sdk |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### Send Message |
| 22 | +```python |
| 23 | + from sdk.api.message import Message |
| 24 | + from sdk.exceptions import CoolsmsException |
| 25 | + |
| 26 | + # set api key, api secret |
| 27 | + api_key = "#ENTER_YOUR_OWN#" |
| 28 | + api_secret = "#ENTER_YOUR_OWN#" |
| 29 | + |
| 30 | + ## 4 params(to, from, type, text) are mandatory. must be filled |
| 31 | + params = dict() |
| 32 | + params['type'] = 'sms' # Message type ( sms, lms, mms, ata ) |
| 33 | + params['to'] = '01000000000' # Recipients Number '01000000000,01000000001' |
| 34 | + params['from'] = '01000000000' # Sender number |
| 35 | + params['text'] = 'Test Message' # Message |
| 36 | + |
| 37 | + cool = Message(api_key, api_secret) |
| 38 | + try: |
| 39 | + response = cool.send(params) |
| 40 | + print("Success Count : %s" % response['success_count']) |
| 41 | + print("Error Count : %s" % response['error_count']) |
| 42 | + print("Group ID : %s" % response['group_id']) |
| 43 | + |
| 44 | + if "error_list" in response: |
| 45 | + print("Error List : %s" % response['error_list']) |
| 46 | + |
| 47 | + except CoolsmsException as e: |
| 48 | + print("Error Code : %s" % e.code) |
| 49 | + print("Error Message : %s" % e.msg) |
| 50 | +``` |
| 51 | + |
| 52 | +### Message History |
| 53 | +```python |
| 54 | + from sdk.api.message import Message |
| 55 | + from sdk.exceptions import CoolsmsException |
| 56 | + |
| 57 | + # set api key, api secret |
| 58 | + api_key = "#ENTER_YOUR_OWN#" |
| 59 | + api_secret = "#ENTER_YOUR_OWN#" |
| 60 | + |
| 61 | + cool = Message(api_key, api_secret) |
| 62 | + try: |
| 63 | + i = 0 |
| 64 | + response = cool.sent() |
| 65 | + for data in response['data']: |
| 66 | + i += 1 |
| 67 | + print("Message No.%s" % i) |
| 68 | + print("Type : %s" % data['type']) |
| 69 | + print("Accepted_time : %s" % data['accepted_time']) |
| 70 | + print("Recipient_number : %s" % data['recipient_number']) |
| 71 | + print("Group_id : %s" % data['group_id']) |
| 72 | + print("Message_id : %s" % data['message_id']) |
| 73 | + print("Status : %s" % data['status']) |
| 74 | + print("Result_code : %s" % data['result_code']) |
| 75 | + print("Result_message : %s" % data['result_message']) |
| 76 | + print("Sent_time : %s" % data['sent_time']) |
| 77 | + print("Text : %s" % data['text']) |
| 78 | + print("Carrier : %s" % data['carrier']) |
| 79 | + print("Scheduled_time : %s" % data['scheduled_time']) |
| 80 | + |
| 81 | + except CoolsmsException as e: |
| 82 | + print("Error Code : %s" % e.code) |
| 83 | + print("Error Message : %s" % e.msg) |
| 84 | +``` |
| 85 | + |
| 86 | +If you want more examples. Visit to 'http://www.coolsms.co.kr/Python_SDK_Example'. |
| 87 | + |
| 88 | +## Information |
| 89 | + |
| 90 | +Look at the 'http://www.coolsms.co.kr/Python_SDK_Start_here' |
0 commit comments