Sending SMS, MMS using Twilio.

Twilio is a cloud communications platform. you can send text or pictures around the world. here is simple demo how to send sms using python

Install Twilio python packege

pip install twilio

Sending a Text Message:

    from twilio.rest import TwilioRestClient

    account_sid = "your_twilio_account_sid"

    auth_token = "your_twilio_auth_token"

    # initialising twilio rest client

    client = TwilioRestClient(account_sid, auth_token)

    # sending your messge to twilio que

    msg = client.messages.create(body="Test message", to="reciever_number", from_="your_twilio_mobile_number")

Get last sent message status:

    client = TwilioRestClient(account_sid, auth_token)

    last_sms = client.messages.list()[0]

    print last_sms.status

    'delivered'

    print last_sms.body

    'Test message'

Sending a Picture Message:

    client = TwilioRestClient(account_sid, auth_token)

    message = client.messages.create(

        body="Test mms",  # Message body

        to="reciever_number",

        from_="your_twilio_mobile_number",

        media_url="http://micropyramid.com/logo.png"

    )

Posted On 22 January 2016 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
QRCode generation in python

A Quick Response code(QRCode) is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules ...

Continue Reading...
Getting Started with the IPython Notebook

IPython is a set of tools developed to make it easier for the programmers to work with Python and data. IPython provides extensions to the ...

Continue Reading...
Python to Debian package: Simple, Easy and Fast

Packaging python script to debian follows strict instructions, using the following instructions, most of the steps can be skipped hence making it easy and fast.
Continue Reading...

open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties