Sending SMS, MMS using Twilio.

Reading Time : ~ .

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"

    )
    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Publishing Python Modules with PIP via PyPi Ashwin Kumar

We'll install so many packages in our day to day python development. Now in this blog post, we'll try to know how to create our ...

Continue Reading...
Create excel file, Insert image, Draw Bar Graphs in excel files in python using xlsxwriter Chaitanya Kattineni

Xlsxwriter is a python module through which we can write data to Excel 2007+ XLSX file format. In this blog post we learn to write ...

Continue Reading...
Working with python collections part 1 Rakesh babu Podishetty

Python Collections - named tuple is to access by the names specified and deque is to append and pop the elements from both sides of ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties