-
Notifications
You must be signed in to change notification settings - Fork 6
/
MMS.py
30 lines (25 loc) · 1.05 KB
/
MMS.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
# Download the helper library from https://www.twilio.com/docs/python/install
import sys
from twilio.rest import Client
from SMS import Send_SMS
import ConfigValues
def Send_MMS(MMS_Message, MMS_Destination, URL):
try:
# Your Account Sid and Auth Token from twilio.com/console
# DANGER! This is insecure. See http://twil.io/secure
account_sid = ConfigValues.ReturnTwilioSID()
auth_token = ConfigValues.ReturnTwilioAuthToken()
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body=MMS_Message,
from_= ConfigValues.ReturnTwilioSourcePhone(),
#URL Must be publicly available and not require authentication
media_url=[URL],
to=MMS_Destination
)
print('MMS Sent Message ID: ' + message.sid)
except:
print("Oops!, MMS Error: ", sys.exc_info()[0], "occurred.")
FailMessage = "MMS Failure, Fallback to SMS: " + MMS_Message
Send_SMS(FailMessage, MMS_Destination)