forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-utils.py
More file actions
executable file
·29 lines (22 loc) · 1005 Bytes
/
Copy pathexample-utils.py
File metadata and controls
executable file
·29 lines (22 loc) · 1005 Bytes
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
#!/usr/bin/env python
import twilio
# Twilio AccountSid and AuthToken
ACCOUNT_SID = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
ACCOUNT_TOKEN = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
# Create a Twilio utility object using your Twilio account ID and token
utils = twilio.Utils(ACCOUNT_SID, ACCOUNT_TOKEN)
# ===========================================================================
# 1. Validate a Twilio request
# the URL and POST parameters would typically be provided by the web
# framework that is recieving the request from Twilio (e.g. Django)
url = "http://UUUUUUUUUUUUUUUUUU"
postvars = {}
# the request from Twilio also includes the HTTP header: X-Twilio-Signature
# containing the expected signature
signature = "SSSSSSSSSSSSSSSSSSSSSSSSSSSS"
print "The request from Twilio to %s with the POST parameters %s " % \
(url, postvars)
if utils.validateRequest(url, postVar, signature):
print "was confirmed to have come from Twilio."
else:
print "was NOT VALID. It might have been spoofed!"