PYTHON SDK
v2.0.3
add_messages.py
이 파일의 문서화 페이지로 가기
1 # vi:set sw=4 ts=4 expandtab:
2 # -*- coding: utf8 -*-
3 
4 import sys
5 
6 sys.path.insert(0, "../../")
7 
8 from sdk.api.group_message import GroupMessage
9 from sdk.exceptions import CoolsmsException
10 
11 ## @brief This sample code demonstrate how to add messages into group through CoolSMS Rest API
12 if __name__ == "__main__":
13 
14  # set api key, api secret
15  api_key = "#ENTER_YOUR_OWN#"
16  api_secret = "#ENTER_YOUR_OWN#"
17 
18  # Options(group_id, to, from, text) are mandatory. must be filled
19  params = dict()
20  params["type"] = "sms" # Message type ( sms, lms, mms, ata )
21  params['to'] = '01000000000' # Recipients Number '01000000000,01000000001'
22  params['from'] = '01000000000' # Sender number
23  params['text'] = 'Test Message' # Message
24  params["group_id"] = "GID57A82D462CBBF" # Group ID
25 
26  # Optional parameters for your own needs
27  # params["image_id"] = "image_id" # image_id. type must be set as 'MMS'
28  # params["refname"] = "" # Reference name
29  # params["country"] = "82" # Korea(82) Japan(81) America(1) China(86) Default is Korea
30  # params["datetime"] = "20140106153000" # Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00)
31  # params["subject"] = "Message Title" # set msg title for LMS and MMS
32  # params["delay"] = "10") # '0~20' delay messages
33  # params["sender_key"] = "5554025sa8e61072frrrd5d4cc2rrrr65e15bb64" # 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk
34  # params["template_code"] = "C004" # 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요.
35 
36  cool = GroupMessage(api_key, api_secret)
37 
38  try:
39  response = cool.add_messages(params)
40  print("Success Count : %s" % response['success_count'])
41  print("Error Count : %s" % response['error_count'])
42 
43  if "error_list" in response:
44  print("Error List : %s" % response['error_list'])
45 
46  except CoolsmsException as e:
47  print("Error Code : %s" % e.code)
48  print("Error Message : %s" % e.msg)
49 
50  sys.exit()
management group message, using Rest API