Skip to content

Instantly share code, notes, and snippets.

@limitpointinf0
Last active June 9, 2018 02:54
Show Gist options
  • Save limitpointinf0/ef55f3b86cff95b78181ea4cc55ab8d1 to your computer and use it in GitHub Desktop.
Save limitpointinf0/ef55f3b86cff95b78181ea4cc55ab8d1 to your computer and use it in GitHub Desktop.
Send an SMS using Twilio API
# 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