python类TwilioRestClient()的实例源码

Execute_Instructions_Remotely.py 文件源码 项目:Cool-Scripts 作者: Anishka0107 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def check_and_run() :
    imap_conn = imapclient.IMAPClient (domain_name, ssl = True)
    print (imap_conn)
    try :
        print (imap_conn.login (emailaddress, password))
    except :
        print ('Wrong username password combination! Please try again.')
        sys.exit()
    print (imap_conn.select_folder ('INBOX', readonly = False))
    uids = imap_conn.gmail_search ('label:' + label + ' label:Inbox ' + emailaddress + ' subject:' + mysubject + ' label:unread')
    print (uids)
    messages = imap_conn.fetch (uids, ['BODY[]'])
    for x in messages.keys() :
        lstcomm = pyzmail.PyzMessage.factory (messages[x][b'BODY[]'])
        commands.append (lstcomm.text_part.get_payload().decode (lstcomm.text_part.charset))   
    print (imap_conn.logout())
    twilioClient = TwilioRestClient (twilioSID, twilioAuthToken)
    for x in commands[::-1] :
        newfile = open ('commandstorun.py', 'w')
        newfile.write ('#! /usr/bin/python3\n')
        newfile.write (x)
        newfile.close()
        os.system ('chmod +x commandstorun.py')
        os.system ('./commandstorun.py')
        print ('Executed script :\n' + x)
        msg = twilioClient.messages.create (body = 'Your script has been executed! ' + x, from_ = sender, to = receiver)        
        print (msg.status)
Chap16ProjTextMyself.py 文件源码 项目:Pythonlearn 作者: godzoco 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def textmyself(message):
    twilioCli = TwilioRestClient(accountSID, authToken)
    twilioCli.messages.create(body=message, from_=twilioNumber, to=myNumber)
test_credentials.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_creds_error(creds):
    creds.return_value = (None, None)
    assert_raises(TwilioException, TwilioRestClient)
test_client.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN")
        self.task_router_client = TwilioTaskRouterClient("ACCOUNT_SID",
                                                         "AUTH_TOKEN")
test_client.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN",
                                       timeout=sentinel.timeout)
sms.py 文件源码 项目:screeps_notify 作者: screepers 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def getClient(self):
        if self.smsclient:
            return self.smsclient
        assert 'twilio_sid' in self.settings
        self.smsclient = TwilioRestClient(self.settings['twilio_sid'],
                                          self.settings['twilio_token'])
        return self.smsclient
server.py 文件源码 项目:postmatesgt 作者: tirril29 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        self.map = {}
        self.brd = {}
        exec(open('./twilio.json').read())
        print
        sid = x['twilio']['account_sid']
        sec = x['twilio']['secret']

        self.twilio = TwilioRestClient(sid, sec)
sms.py 文件源码 项目:suite 作者: Staffjoy 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _get_twilio_client():
    """Return twilio rest client with variables"""
    return TwilioRestClient(
        current_app.config.get("TWILIO_ACCOUNT_SID"),
        current_app.config.get("TWILIO_AUTH_TOKEN"))
alerts.py 文件源码 项目:elastalert-ui 作者: steelheaddigital 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def alert(self, matches):
        client = TwilioRestClient(self.twilio_accout_sid, self.twilio_auth_token)

        try:
            client.messages.create(body=self.rule['name'],
                                   to=self.twilio_to_number,
                                   from_=self.twilio_to_number)

        except TwilioRestException as e:
            raise EAException("Error posting to twilio: %s" % e)

        elastalert_logger.info("Trigger sent to Twilio")
tasks.py 文件源码 项目:django-channels-celery-websocket-example 作者: rollokb 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def send_phone_code(user_id, verify_token, phone_number):
    customer = Customer.objects.get(id=user_id)

    # simulating a short delay
    sleep(randint(3, 9))

    client = TwilioRestClient(  # noqa
        settings.TWILLO_API_KEY,
        settings.TWILLO_AUTH_TOKEN,
    )

    try:
        client.messages.create(
            to=phone_number,
            from_=settings.TWILLO_FROM_NUMBER,
            body="Your Verify Code is {}".format(
                verify_token
            )
        )
        # Notify the FE task has completed
        Group('phone_verify-%s' % customer.username).send({
            'text': json.dumps({
                'success': True,
                'msg': 'new message sent'
            })
        })
    except TwilioRestException as e:
        Group('phone_verify-%s' % customer.username).send({
            'text': json.dumps({
                'success': False,
                'msg': e.msg
            })
        })
views.py 文件源码 项目:smslists 作者: alando46 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def send_message(request, source, destination, menu_text):
    client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) 

    client.messages.create(
        to=destination, 
        from_=source, 
        body=menu_text,  
    )
    request.session['last_message'] = menu_text
cunyenrollment.py 文件源码 项目:CUNYFirst-Enrollment-Bot 作者: Maxthecoder1 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def textmyself(self, message):
        twilioCli = TwilioRestClient(self.accountsid, self.authtoken)
        twilioCli.messages.create(body=message, from_=self.twiliocell, to=self.mycellphone)
        print("successfully sent the text")
textMyself.py 文件源码 项目:AutomateTheBoringStuff 作者: JPHaus 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def textmyself(message):
    twilioCli = TwilioRestClient(accountSID, authToken)
    twilioCli.messages.create(body = message, from_ = twilioNumber, to = myNumber)
SendMessage.py 文件源码 项目:catFaceSwapSendToTodd 作者: Micasou 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def sendMessage(mediaURL):
    client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) 
    client.messages.create(
        to="+14254298436", 
        from_="+19284874422 ", 
        media_url=mediaURL, 
    )    
    return
iris_twilio.py 文件源码 项目:iris 作者: linkedin 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_twilio_client(self):
        return TwilioRestClient(self.config['account_sid'],
                                self.config['auth_token'])
test_credentials.py 文件源码 项目:alexa-ive-fallen-and-cant-get-up 作者: heatherbooker 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_creds_error(creds):
    creds.return_value = (None, None)
    assert_raises(TwilioException, TwilioRestClient)
test_client.py 文件源码 项目:alexa-ive-fallen-and-cant-get-up 作者: heatherbooker 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN")
        self.task_router_client = TwilioTaskRouterClient("ACCOUNT_SID",
                                                         "AUTH_TOKEN")
test_client.py 文件源码 项目:alexa-ive-fallen-and-cant-get-up 作者: heatherbooker 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN",
                                       timeout=sentinel.timeout)
sender.py 文件源码 项目:amonone 作者: amonapp 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def send_test_sms(recepient=None):
    details = sms_model.get()
    client = TwilioRestClient(details['account'], details['token'])

    t = threading.Thread(target=_send_sms_in_thread, 
                kwargs={"client": client,
                    "from_": details['from_'],
                    "to": recepient,
                    "body": "Amon alert!"
                })
    t.start()


问题


面经


文章

微信
公众号

扫码关注公众号