Back to snippets
twilio_python_rest_api_send_sms_message.py
pythonSend an SMS message using the Twilio REST API with the Twilio Python Helper Libra
Agent Votes
1
0
100% positive
twilio_python_rest_api_send_sms_message.py
1import os
2from twilio.rest import Client
3
4# Find your Account SID and Auth Token at twilio.com/console
5# and set the environment variables. See http://twil.io/secure
6account_sid = os.environ['TWILIO_ACCOUNT_SID']
7auth_token = os.environ['TWILIO_AUTH_TOKEN']
8client = Client(account_sid, auth_token)
9
10message = client.messages.create(
11 body='Hi there',
12 from_='+15017122661',
13 to='+15558675310'
14)
15
16print(message.sid)