Text (Twilio) - HomeMadePy/messages GitHub Wiki
The text module provides an easy and intuitive interface to construct and send text messages. Currently the only text message service offered is twilio
Twilio API
Twilio(**from_**=None, to=None, auth=None, body='', attachments=None, verbose=False)
- from_: (str) The phone number the message will originate from, i.e. '+16195553232'.
- to: (str) [required] The destination phone number.
- body: (str) [optional] The body text of the message to send. Use body text from a file by setting body=file.read().
- auth: (list or tuple) twilio api credentials: (acct_sid, auth_token). May use environment variables to pull auth credentials or whatever means you feel necessary.
- attachments: (str) [optional] a url, who's content you wish to attach in the message, such as a url for a picture.
- verbose: (bool) [optional] print verbose output.
Usage
After instantiating a Twilio object, using the API above, the following method can be used to send the message:
- send(): sends the message synchronously
Example
Script/REPL
>>> from messages import Twilio
>>> t = Twilio(
from_='+16195553232',
to='+16198675309',
auth=('ACjfkldjl', 'asdjfklsdfianfd'),
body='TestMessage',
attachments='https://imgs.xkcd.com/comics/python.png',
)
>>> t.send()
Message sent...
Twilio Service
In order to use this service, you must register with twilio, purchase a from_ number, and get the required API credentials. This is a paid service.