Skip to content

rahul08M/python-twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

python-twilio

Free SMS Using Twilio and Python

1. Setup Twilio Account

Go to the Twilio site and get register yourself. https://www.twilio.com/

Twillio Register 0.1

2. Once you get registered, verify your Email ID.

3. Once your email id gets verified, you need to add and verify your mobile number. (You will receive the OTP)

Twillio OTP 0.1

4. After mobile and email verification fill in the basic information.

Twillio Bisc info 0.1

5. Twilio provides a virtual mobile number to send the SMS for the free account. You need to click on the (Get Virtual Phone Number) button.

Twillio Virtual number

6. Grab the Account SID, Account Token, and Twilio Virtual Phone Number.

Account SID is a security identifier.
Account Token used to access the API

Twillio keys

7. For the trail/free version, you can only send messages to verified caller ids.

Integrating Twilio API using Python

1. Create/Setup a Python virtual environment

# install the virtual environment
>>> pip3 install -U virtualenv
>>> mkdir python-twilio-sender
>>> cd python-twilio-sender
>>> virtualenv venv
# activate the virtual environment
>>> source venv/bin/activate
(venv) prompt$

2. Install twilio python library/SDK

https://www.twilio.com/docs/libraries/python#install-the-library

>>> pip3 install twilio

3. Simple code snippet to send the SMS

from twilio.rest import Client
# Your Account SID from twilio.com/console
account_sid = "<account_sid>"
# Your Auth Token from twilio.com/console
auth_token  = "your_auth_token"
client = Client(account_sid, auth_token)
message = client.messages.create(
    to="+15558675309", 
    from_="+15017250604",
    body="Hello from Python!")
print(message.sid)

Notes :

A) Auth token and Account SID must be sorted in the OS.
B) For the trial version “to” number must be first verified.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages