Python django.conf.settings.TWILIO_AUTH_TOKEN Examples
The following are 11
code examples of django.conf.settings.TWILIO_AUTH_TOKEN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.conf.settings
, or try the search function
.
Example #1
Source File: tasks.py From betterself with MIT License | 6 votes |
def send_supplement_reminder(supplement_reminder_id): reminder = SupplementReminder.objects.get(id=supplement_reminder_id) reminder_text = 'BetterSelf.io - Daily Reminder to take {} of {}! Reply DONE when done!'.format( reminder.quantity, reminder.supplement.name) phone_to_text = reminder.user.userphonenumberdetails.phone_number.as_e164 # autosave prior to sending to client, just in case twilio is down # this would queue up too many things reminder.last_sent_reminder_time = get_current_utc_time_and_tz() reminder.save() client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) client.messages.create( to=phone_to_text, from_=settings.TWILIO_PHONE_NUMBER, body=reminder_text)
Example #2
Source File: base.py From django-herald with MIT License | 5 votes |
def _send(recipients, text_content=None, html_content=None, sent_from=None, subject=None, extra_data=None, attachments=None): try: # twilio version 6 from twilio.rest import Client except ImportError: try: # twillio version < 6 from twilio.rest import TwilioRestClient as Client except ImportError: raise Exception( "Twilio is required for sending a TwilioTextNotification." ) try: account_sid = settings.TWILIO_ACCOUNT_SID auth_token = settings.TWILIO_AUTH_TOKEN except AttributeError: raise Exception( "TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN settings are required for sending a TwilioTextNotification" ) client = Client(account_sid, auth_token) for recipient in recipients: client.messages.create(body=text_content, to=recipient, from_=sent_from)
Example #3
Source File: sms.py From django-db-mailer with GNU General Public License v2.0 | 5 votes |
def send(sms_to, sms_body, **kwargs): """ Site: https://www.twilio.com/ API: https://www.twilio.com/docs/api/rest/sending-messages """ headers = { "Content-type": "application/x-www-form-urlencoded", "User-Agent": "DBMail/%s" % get_version(), 'Authorization': 'Basic %s' % b64encode( "%s:%s" % ( settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN )).decode("ascii") } kwargs.update({ 'From': kwargs.pop('sms_from', settings.TWILIO_FROM), 'To': sms_to, 'Body': from_unicode(sms_body) }) http = HTTPSConnection(kwargs.pop("api_url", "api.twilio.com")) http.request( "POST", "/2010-04-01/Accounts/%s/Messages.json" % settings.TWILIO_ACCOUNT_SID, headers=headers, body=urlencode(kwargs)) response = http.getresponse() if response.status != 201: raise TwilioSmsError(response.reason) return loads(response.read()).get('sid')
Example #4
Source File: gateways.py From cadasta-platform with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self): self.client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
Example #5
Source File: validators.py From intake with MIT License | 5 votes |
def is_valid_twilio_request(request): twilio_request_validator = RequestValidator(settings.TWILIO_AUTH_TOKEN) request_path = request.build_absolute_uri( request.get_full_path()).replace('http:', 'https:') # trailing slashes should be removed if request_path[-1] == '/': request_path = request_path[:-1] twilio_signature = request.META.get('HTTP_X_TWILIO_SIGNATURE', '') return twilio_request_validator.validate( request_path, request.POST, twilio_signature)
Example #6
Source File: twilio.py From django-smsish with MIT License | 5 votes |
def _get_twilio_client(self): account = settings.TWILIO_ACCOUNT_SID token = settings.TWILIO_AUTH_TOKEN client = TwilioRestClient(account, token) return client
Example #7
Source File: tasks.py From betterself with MIT License | 5 votes |
def send_verification_text(phone_number): client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) client.messages.create( to=phone_number, from_=settings.TWILIO_PHONE_NUMBER, body="BetterSelf.io - Please verify your number by replying with 'VERIFY'. Thanks!")
Example #8
Source File: tasks.py From betterself with MIT License | 5 votes |
def send_thanks_for_verification_text(phone_number): client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) client.messages.create( to=phone_number, from_=settings.TWILIO_PHONE_NUMBER, body='BetterSelf.io - Your phone number has been verified. Thanks!')
Example #9
Source File: tasks.py From betterself with MIT License | 5 votes |
def send_log_confirmation(supplement_event, number): client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) # if only you could send http links prettier in text messages message = "BetterSelf.io/dashboard/log/supplements_events/ - We've logged your record of {}. Thanks!" \ .format(supplement_event.supplement.name) client.messages.create( to=number, from_=settings.TWILIO_PHONE_NUMBER, body=message)
Example #10
Source File: notifications.py From TheSpaghettiDetective with GNU Affero General Public License v3.0 | 5 votes |
def send_sms(msg, to_number): twilio_client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) from_number = settings.TWILIO_FROM_NUMBER twilio_client.messages.create(body=msg, to=to_number, from_=from_number)
Example #11
Source File: notify.py From sensu_drive with MIT License | 4 votes |
def __init__(self, message): self.entity = message['entity'] self.status = int(message['status']) self.output = message['output'] if int(message['status']) == 0: self.color = '#36a64f' self.twilio_msg_prefix = 'recovery notification.' self.twilio_msg_postfix = 'is okay!' elif int(message['status']) == 1: self.color = '#FFA500' self.twilio_msg_prefix = 'this is a warning!' self.twilio_msg_postfix = 'is in status warning!' elif int(message['status']) == 2: self.color = '#C74350' self.twilio_msg_prefix = 'bad news, this is a critical notification!' self.twilio_msg_postfix = 'is in status critical!' else: self.color = '' self.twilio_msg_prefix = 'unknown notification.' self.twilio_msg_postfix = 'is in status unknown!' slack_alert_template = get_template('isubscribe/slack_alert.txt') self.slack_msg_content_fallback = slack_alert_template.render({ 'entity': self.entity, 'status': self.status, 'output':self.output }) self.slack_attachments = [{ "fallback": self.slack_msg_content_fallback, "title": self.entity, "title_link": "%s%s" % (settings.REGISTRATION_URL_PREFIX, reverse_lazy('events')), "text": self.output, "color": self.color, "author_name": settings.SLACK_BOT_NAME, "author_link": "%s%s" % (settings.REGISTRATION_URL_PREFIX, reverse_lazy('events')), "author_icon": settings.SLACK_BOT_ICON, }] twilio_msg_formated = self.twilio_msg_prefix + ' ' + self.entity + ' ' + self.twilio_msg_postfix self.twilio_params = { 'msg' : twilio_msg_formated, 'api_token' : settings.TWILIO_CALLBACK_API_TOKEN, 'entity': self.entity, 'status': self.status } self.twilio_client = TwilioRestClient(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) self.slack_delivery_to = [] self.twilio_delivery_to = []