def get_sms_client(): """Generic function get an SMS client object. This only works with Twilio at this time.""" # check to see if there's a provider set if config.configs['smsaction.provider'] == None or len( config.configs['smsaction.provider']) == 0: errormessage = 'SMS Actions are enabled but smsaction.provider value is not set, exiting' log.logger.error(errormessage) raise ValueError(errormessage) # load code for Twilio elif config.configs['smsaction.provider'].lower() == 'twilio': # these need to be in the global name space to send SMS messages global twilio import twilio global twiliorest import twilio.rest as twiliorest global smsclient smsclient = twiliorest.Client(config.configs['smsaction.account_id'], config.configs['smsaction.auth_token']) return smsclient # unknown SMS provider error else: errormessage = 'SMS Actions are enabled but found unknown smsaction.provider {}, exiting'.format( config.configs['smsaction.provider']) log.logger.error(errormessage) raise ValueError(errormessage)
def sms(): client = rest.Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) message = client.messages.create(to="+15558675309", from_="+18317776235", body="Hello from Python!", media_url='') print(message.sid)
def __init__(self): config = ConfigParser() config.read('config.ini') self.spotify_user = config['SPOTIFY']['SPOTIFY_USER'] self.spotipy_client_id = config['SPOTIFY']['SPOTIPY_CLIENT_ID'] self.spotipy_client_secret = config['SPOTIFY']['SPOTIPY_CLIENT_SECRET'] self.spotipy_redirect_uri = config['SPOTIFY']['SPOTIPY_REDIRECT_URI'] self.spotify_user = config['SPOTIFY']['SPOTIFY_USER'] self.source_playlist_id = config['SPOTIFY']['SOURCE_PLAYLIST_ID'] self.target_playlist_id = config['SPOTIFY']['TARGET_PLAYLIST_ID'] self.receiver_no = config['NUMBERS']['RECEIVER_NO'] self.error_receiver_no = config['NUMBERS']['ERROR_RECEIVER_NO'] self.sending_no = config['NUMBERS']['SENDING_NO'] self.twilio_sid = config['TWILIO']['TWILIO_SID'] self.twilio_token = config['TWILIO']['TWILIO_TOKEN'] self.spotify_client = spotipy.Spotify( auth_manager=SpotifyOAuth(client_id=self.spotipy_client_id, client_secret=self.spotipy_client_secret, redirect_uri=self.spotipy_redirect_uri, scope=SPOTIFY_SCOPES, cache_path='.sp_cache')) self.twilio_client = twilio.Client(self.twilio_sid, self.twilio_token) self.logger = logging.getLogger("SendSpotifyLove") self.logger.setLevel(logging.INFO) self.logger.addHandler(logging.StreamHandler())
def send_update(body): """ Send message to self from FaceBook Bot :param body: text to be send :return: send notification to FB Messenger """ # Logging into Bot cookies = {} try: client = fbchat.Client(email=os.getenv("FB_USERNAME"), password=os.getenv("FB_PASSWORD"), session_cookies=cookies) datetime = get_current_timestep() text = datetime['full'] + '\t\n\n' text += body # Personal FB UID (Sawyer Ruben) UID = int(os.getenv("FB_UID")) with open('session.json', 'w') as f: json.dump(client.getSession(), f) client.send(fbchat.Message(text=text), thread_id=UID, thread_type=fbchat.ThreadType.USER) client.logout() except: account_sid = os.getenv('TWILIO_ACC_SID') auth_token = os.getenv('TWILIO_AUTH_TOKEN') client = twilio.Client(account_sid, auth_token) message = client.messages.create( body="ERROR logging into Albert Facebook", from_='+12092314126', to=os.getenv('PHONE'))
def send_sms(message): client = rest.Client(cd.account_sid, cd.auth_token) my_msg = message message = client.messages.create(to=cd.my_cell, from_=cd.my_twilio, body=my_msg)
def send_text_message(self, number): account_sid = "AC6ea547f6193e305f11ad917dcb4d1bb6" # Your Auth Token from twilio.com/console auth_token = "185116e72070699a2fc180fda82573de" client = rest.Client(account_sid, auth_token) message = client.messages.create(to=number, from_="+15012264574", body="the reservation complete :)")
def act(self, event: Event): print("{} acting on {}".format(__name__, event)) client = tr.Client(self.account_sid, self.auth_token) message = client.messages.create(to=self.to_phone, from_=self.from_phone, body="pivpn update\n" + event.message) return message
def send_sms(): """Sends a simple SMS message.""" to = request.args.get('to') if not to: return ('Please provide the number to message in the "to" query string' ' parameter.'), 400 client = rest.Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) rv = client.messages.create(to=to, from_=TWILIO_NUMBER, body='Hello from Twilio!') return str(rv)
def twilio_client(self): """ Returns an authenticated Twilio SDK """ try: twilio_client = twilio_rest.Client(self.account_sid, self.auth_token) except Exception as e: raise notification_utils.TwilioException( f"{self} failed to set up Twilio client with {e}" ) return twilio_client
def send_Msg(): # Your Account SID from twilio.com/console account_sid = "[Account Id]" # Your Auth Token from twilio.com/console auth_token = "[Token]" client = Rest.Client(account_sid, auth_token) message = client.messages.create(to="+16412260165", from_="+16416385058", body="Hello from Python!") print(message.sid)
def message(): # Your Account SID from twilio.com/console account_sid = "AC3e4288c8901128c118c96ae7a6ac1fd6" # Your Auth Token from twilio.com/console auth_token = "452d329097e569949361afafaa11bff9" client = rest.Client(account_sid, auth_token) message = client.messages.create( to="+12026880925", from_="+917689961477", body="Hello from Python!") print(message.sid)
def get_sms_client(): """Generic function get an SMS client object. This only works with Twilio at this time.""" # check to see if there's a provider set if config.configs['smsaction.provider'] == None or len( config.configs['smsaction.provider']) == 0: errormessage = u'SMS Actions are enabled but smsaction.provider value is not set, exiting' log.logger.error(errormessage) raise ValueError(errormessage) # load code for Twilio elif config.configs['smsaction.provider'].lower() == 'twilio': # these need to be in the global name space to send SMS messages global twilio import twilio # Monkey patch to allow Twilio to find the cacert.pem file even when compiled into an exe # See: https://stackoverflow.com/questions/17158529/fixing-ssl-certificate-error-in-exe-compiled-with-py2exe-or-pyinstaller # and https://github.com/twilio/twilio-python/issues/167 ca_cert_path = os.path.join('twilio', 'conf', 'cacert.pem') from twilio.http import get_cert_file get_cert_file = lambda: ca_cert_path twilio.http.get_cert_file = get_cert_file global twiliorest import twilio.rest as twiliorest global smsclient smsclient = twiliorest.Client(config.configs['smsaction.account_id'], config.configs['smsaction.auth_token']) return smsclient # unknown SMS provider error else: errormessage = u'SMS Actions are enabled but found unknown smsaction.provider {}, exiting'.format( config.configs['smsaction.provider']) log.logger.error(errormessage) raise ValueError(errormessage)
def on_message(client, userdata, msg): msg_str = msg.payload.decode("UTF-8") alert_msg = ast.literal_eval(msg_str) account_sid = os.getenv('TWILIO_SID', None) auth_token = os.getenv('TWILIO_TOKEN', None) twilio_phone = os.getenv('TWILIO_NUMBER', None) if not account_sid or not auth_token or not twilio_phone: return client = twilio.Client(account_sid, auth_token) msg = build_message(alert_msg['user'], alert_msg['departure'], alert_msg['arrival']) destination_phone = alert_msg['user']['phoneNumber'] message = client.messages.create(body=msg, from_=twilio_phone, to=destination_phone)
# Sending an SMS using the Twilio API from twilio import rest # put your own credentials here account_sid = "ACf8c21d1fd4a593deb2a2d2b45367ec87" auth_token = "2a7b427096afb43d5d7d6aea03fdcec1" client = rest.Client(account_sid, auth_token) message = client.messages.create( to="+201286970220", # vertified phone number from trello from_="+14158623509", # phone number recieved by trello body="Tomorrow's forecast in Financial District, San Francisco is Clear", media_url="https://climacons.herokuapp.com/clear.png") print(message.sid)
# Establish a secure session with gmail's outgoing SMTP server using your gmail account # server = smtplib.SMTP("smtp.gmail.com", 587) # server.starttls() logon_id = os.getenv('logon_id') logon_pwd = os.getenv('logon_pwd') binance_api = os.getenv('api_key') binacne_secret = os.getenv('secret_key') twilio_sid = os.getenv('twilio_sid') twilio_token = os.getenv('twilio_token') cryptopia_api = os.getenv('cryptopia_api') cryptopia_secret = os.getenv('cryptopia_secret') server = TwilioClient.Client(twilio_sid, twilio_token) phone = os.getenv('phone') from_phone = os.getenv('from_phone') cryptopia = Exchange(cryptopia_api, cryptopia_secret, Exchange.EX_CRYPTOPIA) binance = Exchange(binance_api, binacne_secret, Exchange.EX_BINANCE) bittrex = Exchange(binance_api, binacne_secret, Exchange.EX_BITTREX) yobit = Exchange(binance_api, binacne_secret, Exchange.EX_YOBIT) poloniex = Exchange(binance_api, binacne_secret, Exchange.EX_POLONIEX) binance.add_coin_symbol('ICX', 'BTC', all_exchange=False, name='ICON') binance.add_coin_symbol('VEN', 'BTC', all_exchange=False, name='VeChain') binance.add_coin_symbol('BTC', 'USDT', all_exchange=False, name='Bitcoin') binance.add_coin_symbol('TRX', 'BTC', all_exchange=False, name='TRON') binance.add_coin_symbol('LTC', 'BTC', all_exchange=False, name='Litecoin')
s = s.replace('%'+k+'%', v) return s def random_token(): return base64.urlsafe_b64encode(os.urandom(256 // 8)).decode().strip('=') try: twilio_client_kwargs = { 'username': secrets['TWILIO_API_KEY'], 'password': secrets['TWILIO_API_SECRET'], 'account_sid': secrets['TWILIO_ACCOUNT_SID'], } except KeyError: twilio_client = None else: twilio_client = twilio_rest.Client(**twilio_client_kwargs) MAX_IN_TWILIO_ROOM = 25 room_created = {} async def assign_twilio_room(ritual, clientId, force_new_room=False): async with ritual.video_room_lock: if force_new_room or not ritual.current_video_room: ritual.current_video_room = ( await asyncio.get_event_loop().run_in_executor(None, twilio_client.video.rooms.create) ) ritual.population_of_current_video_room = 0 room_created[ritual.current_video_room.unique_name] = datetime.now() video_room_id = ritual.current_video_room.unique_name ritual.population_of_current_video_room += 1 if ritual.population_of_current_video_room >= MAX_IN_TWILIO_ROOM + 1:
def whatsapp(): client = rest.Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) message = client.messages.create(to="+14155238886", from_="+14087814962", body="Hello from Python!") print(message.sid)
# -*- coding: utf-8 -*- import twilio.rest as tr account_sid = "ACb0bd9584538498dfd6a5a8870e12a6be" auth_token = "16b45adf0c0361a488842182fb145717" client = tr.Client(account_sid, auth_token) message = client.messages.create(body="电脑被开机", from_="+18506953272", to="+86 18500639286") print(message.sid)
import twilio.rest as tr client = tr.Client('SSID', 'Token') client.messages.create(from_='twilio', to=9392550548, body='Your otp is 9999')
def authenticate(self): TWILIO_ACCT_SID = os.getenv("TWILIO_ACCT_SID") TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN") self.client = Twilio.Client(TWILIO_ACCT_SID, TWILIO_AUTH_TOKEN)