def test_group_message(self): cool = GroupMessage(self.api_key, self.api_secret) ## create group response = cool.create_group() group_id = response['group_id'] self.assertIsNotNone(group_id) ## group list response = cool.get_group_list() self.assertIsNotNone(response['list'][0]) ## add messages params = { 'group_id': group_id, 'to': '01000000000', 'from': '01000000000', 'text': 'TestGroupMessage' } response = cool.add_messages(params) self.assertIsNotNone(response['error_count']) ## add messages json params = [{ "from": "01000000000", "to": "01000000001", "text": "TestGroupMessage" }, { "from": "01000000000", "to": "01000000002", "text": "TestGroupMessage" }] messages = json.dumps(params) response = cool.add_messages_json(group_id, messages) self.assertIsNotNone(response[0]['error_count']) ## get message list params = {'group_id': group_id} try: cool.get_message_list(params) except CoolsmsException as e: # 404는 메시지 내역이 없는 것이기 때문에 테스트 실패사유가 안됨 if e.code == 404: pass ## delete messages message_id = 'TESTMESSAGEID' response = cool.delete_messages(group_id, message_id) self.assertIsNotNone(response['error_count']) ## send try: cool.send(group_id) except CoolsmsException as e: # 402는 잔액부족이기 때문에 테스트 실패사유가 안됨 if e.code == 402: pass
import sys sys.path.insert(0, "../../") from sdk.api.group_message import GroupMessage from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to check group info through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "#ENTER_YOUR_OWN#" api_secret = "#ENTER_YOUR_OWN#" # group_id is mandatory. group_id = "GID57A82D462CBBF" cool = GroupMessage(api_key, api_secret) try: response = cool.get_group_info(group_id) print("Group ID : %s" % response['group_id']) print("Message Count : %s" % response['message_count']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
# -*- coding: utf8 -*- import sys sys.path.insert(0, "../../") from sdk.api.group_message import GroupMessage from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to check group info through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "NCSBQ9QL4QIB6AHB" api_secret = "NO3K7ATJ8B8FKZNWKBNHPDRXUQQTYSE6" # group_id mandatory. must be filled group_id = "GID57A82D462CBBF" # Group ID cool = GroupMessage(api_key, api_secret) try: response = cool.send(group_id) print("Group ID : %s" % response['group_id']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
sys.path.insert(0, "../../") from sdk.api.group_message import GroupMessage from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to delete sms group through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "#ENTER_YOUR_OWN#" api_secret = "#ENTER_YOUR_OWN#" # group_ids is mandatory group_ids = "GID57A82D462CBBFF" # Group IDs "GID57A82D462CBBFF,GID98A82D462CDBFF ..." cool = GroupMessage(api_key, api_secret) try: response = cool.delete_groups(group_ids) print("Success Count : %s" % response['success_count']) print("Error Count : %s" % response['error_count']) if "error_list" in response: print("Error List : %s" % response['error_list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
from sdk.api.group_message import GroupMessage from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate check message list through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "#ENTER_YOUR_OWN#" api_secret = "#ENTER_YOUR_OWN#" # group_id is mandatory params = dict() params['group_id'] = "GID57A82D462CBBF" # Group ID # params["offset"] = "0" // default 0 # params["limit"] = "20" // default 20 cool = GroupMessage(api_key, api_secret) try: response = cool.get_message_list(params) print("Total Count : %s" % response['total_count']) print("Limit : %s" % response['limit']) print("Offset : %s" % response['offset']) print("List : %s" % response['list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
# vi:set sw=4 ts=4 expandtab: # -*- coding: utf8 -*- import sys sys.path.insert(0, "../../") from sdk.api.group_message import GroupMessage from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to check group list through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "#ENTER_YOUR_OWN#" api_secret = "#ENTER_YOUR_OWN#" cool = GroupMessage(api_key, api_secret) try: response = cool.get_group_list() print("Group List : %s" % response['list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
params['text'] = 'Test Message' # Message # Optional parameters for your own needs # params["image_id"] = "image_id" # image_id. type must be set as 'MMS' # params["refname"] = "" # Reference name # params["country"] = "82" # Korea(82) Japan(81) America(1) China(86) Default is Korea # params["datetime"] = "20140106153000" # Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00) # params["subject"] = "Message Title" # set msg title for LMS and MMS # params["delay"] = "10") # '0~20' delay messages # params["sender_key"] = "5554025sa8e61072frrrd5d4cc2rrrr65e15bb64" # 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk # params["template_code"] = "C004" # 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요. json_data.append(params) # 원하는 만큼 params를 넣어줍니다 json_data = json.dumps(json_data) cool = GroupMessage(api_key, api_secret) try: response = cool.add_messages_json(group_id, json_data) for data in response: print("Success Count : %s" % data['success_count']) print("Error Count : %s" % data['error_count']) if "error_list" in response: print("Error List : %s" % response['error_list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
params['to'] = '01000000000' # Recipients Number '01000000000,01000000001' params['from'] = '01000000000' # Sender number params['text'] = 'Test Message' # Message params["group_id"] = "GID57A82D462CBBF" # Group ID # Optional parameters for your own needs # params["image_id"] = "image_id" # image_id. type must be set as 'MMS' # params["refname"] = "" # Reference name # params["country"] = "82" # Korea(82) Japan(81) America(1) China(86) Default is Korea # params["datetime"] = "20140106153000" # Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00) # params["subject"] = "Message Title" # set msg title for LMS and MMS # params["delay"] = "10") # '0~20' delay messages # params["sender_key"] = "5554025sa8e61072frrrd5d4cc2rrrr65e15bb64" # 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk # params["template_code"] = "C004" # 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요. cool = GroupMessage(api_key, api_secret) try: response = cool.add_messages(params) print("Success Count : %s" % response['success_count']) print("Error Count : %s" % response['error_count']) if "error_list" in response: print("Error List : %s" % response['error_list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()
from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to create sms group through CoolSMS Rest API if __name__ == "__main__": # set api key, api secret api_key = "#ENTER_YOUR_OWN#" api_secret = "#ENTER_YOUR_OWN#" # Optional parameters for your own needs params = dict() # params["charset"] = "utf8" # utf8, euckr default value is utf8 # params["srk"] = "293DIWNEK103" # Solution key # params["mode"] = "test" # If 'test' value, refund cash to point # params["only_ata"] = "true" # If 'true' value, only send ata # params["delay"] = "10" # '0~20' delay messages # params["force_sms"] = "true"; # true is always send sms ( default true ) # params["app_version"] = "" # A version cool = GroupMessage(api_key, api_secret) try: response = cool.create_group(params) print("Group ID : %s" % response['group_id']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit()