#!/usr/bin/python3.5
# coding=utf-8
# pip3.5 install aliyun-python-sdk-core-v3
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
import sys
client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou')
request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dysmsapi.aliyuncs.com')
request.set_method('POST')
request.set_protocol_type('https') # https | http
request.set_version('2017-05-25')
request.set_action_name('SendSms')
string = sys.argv[2]
phone_number = sys.argv[1]
message = string.split(";")
print(message)
dict1 = { }
dict1['host'] = message[0]
dict1['time'] = message[1]
dict1['item'] = message[2][0:18]
request.add_query_param('RegionId', 'cn-hangzhou')
request.add_query_param('PhoneNumbers', phone_number)
request.add_query_param('SignName', '美宜佳')
request.add_query_param('TemplateCode', 'SMS_159772654')
request.add_query_param('TemplateParam', dict1)
response = client.do_action(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
添加评论