-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_sms.py
31 lines (25 loc) · 869 Bytes
/
send_sms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from dotenv import load_dotenv
from twilio.rest import Client
load_dotenv()
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
from_number = os.environ['FROM_NUMBER']
to_number = os.environ['TO_NUMBER']
msg_svc_sid = os.environ['MESSAGING_SERVICE_SID']
client = Client(account_sid, auth_token)
### Method 1 ###
# message = client.messages \
# .create(
# body="Join Earth's mightiest heroes. Like Kevin Bacon.",
# from_=from_number,
# to=to_number
# )
### Method 2 ###
message = client.messages \
.create(
messaging_service_sid=msg_svc_sid,
body='Sent from Twilio - My first Messaging Service',
to=to_number
)
print(message.sid)