Last active
June 9, 2018 02:54
-
-
Save limitpointinf0/ef55f3b86cff95b78181ea4cc55ab8d1 to your computer and use it in GitHub Desktop.
Send an SMS using Twilio API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the module | |
import subprocess | |
class TextMessage(): | |
def __init__(self, url, from_, message, creds, number): | |
self.tool = 'curl' | |
self.url = url | |
self.from_ = 'From=%s' % from_ | |
self.message = 'Body=%s' % message | |
self.creds = creds | |
self.number = 'To=%s' % number | |
def send(self): | |
request = [ | |
self.tool, | |
self.url, | |
'-X', | |
'POST', | |
'--data-urlencode', | |
self.number, | |
'--data-urlencode', | |
self.from_, | |
'--data-urlencode', | |
self.message, | |
'-u', | |
self.creds | |
] | |
message = subprocess.Popen(request, stdout=subprocess.PIPE) | |
output = message.communicate() | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment