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"

    )

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
Latest Comments
Related Articles
Python Web Scraping with Beautiful soup Sandeep Jagata

Download all One Piece animation series episodes by scraping site using BeautifulSoup python library.

Continue Reading...
Debugging in Python Ramya Ambati

When something goes wrong with your code instead of using standard debugging techniques such as print statements use debugging tools. I found two great tools ...

Continue Reading...
Generating CSV, Excel files Using Python Shirisha Gaddi

In most of the cases, you need to export the data from your database to different formats. In this post I will show you how ...

Continue Reading...