Ejemplo n.º 1
0
class CCP(object):
    def __init__(self):
        # 初始化REST SDK
        self.rest = REST(serverIP, serverPort, softVersion)
        self.rest.setAccount(accountSid, accountToken)
        self.rest.setAppId(appId)

    def send_template_sms(self,to, datas, tempId):

        result = self.rest.sendTemplateSMS(to, datas, tempId)

        if result.get('statusCode') == '000000':
            return 1 #发送成功
        else:
            return 0 #发送失败
Ejemplo n.º 2
0
class CCP(object):
    '''自己封装的发送短信的辅助类'''
    def __init__(self):
        # 初始化REST SDK
        self.rest = REST(serverIP, serverPort, softVersion)
        self.rest.setAccount(accountSid, accountToken)
        self.rest.setAppId(appId)

    def send_Template_sms(self, to, datas, temp_Id):
        # 初始化REST SDK
        result = self.rest.sendTemplateSMS(to, datas, temp_Id)
        for k, v in result.items():

            if k == 'templateSMS':
                for k, s in v.items():
                    print('%s:%s' % (k, s))
            else:
                print('%s:%s' % (k, v))
Ejemplo n.º 3
0
class CCP(object):
    def __init__(self):
        # 初始化REST SDK
        self.rest = REST(serverIP, serverPort, softVersion)
        self.rest.setAccount(accountSid, accountToken)
        self.rest.setAppId(appId)

    # 发送模板短信
    # @param to 手机号码
    # @param datas 内容数据 格式为数组 例如:{'12','34'},如不需替换请填 ''
    # @param $tempId 模板Id

    def send_template_sms(self, to, datas, tempId):
        result = self.rest.sendTemplateSMS(to, datas, tempId)

        if result.get('statusCode') == '000000':
            # 发送成功
            return 1
        else:
            # 发送失败
            return 0