Use Python to send text messages to mobile phones (based on Twilio)

Source: Internet
Author: User
Tags auth

If you don't know what to do with Python texting, then open your brain hole, such as writing an automatic script, on each anniversary when it automatically give you the designated mobile phone number to send a blessing, and so on, and so on who to implement this function, and see below

Accidentally found Twilio, the official website is https://www.twilio.com

Twilio's introduction--provides the SDK to help you connect with all the people in the world, you can easily call the interface they provide to send text messages to the designated cell phone.

First sign up for a trial account at Twilio's website, and you'll need to bind your phone and get a free Twilio number, from your account interface (Dsahboard) to see the accounts Sid and Auth token, as well as your phone number.

Currently (now is 2018-2-22), the trial account will be given a $, only 1 phone number, can only give the registered mobile phone numbers to send text messages, each send a message charged fees and regional related (to China Mobile phone number is $0.028, the price may change at any time, In other words, you can send 500 text messages during the probation period, one day can also play more than a year.

Refer to Https://www.twilio.com/docs/libraries/python, quickly to implement the function of using Python to send text messages.

First download the Twilio installation package, Https://github.com/twilio/twilio-python/zipball/master

Perform python setup.py install to install

Send the Hello from Python twilio! to your phone, enjoy it, as shown in the following code.

From twilio.rest import Client

# Your account SID from twilio.com/console
account_sid = "Replace with your Account_sid"
# Your Auth Token from twilio.com/console
auth_token  = "Replace with your Auth_token"

client = Client (Account_sid, auth_ token)

message = Client.messages.create (
    to= "+86xxxxxxxxxxx, replaced by the registered mobile phone number, which is to receive SMS phone number, China area is +86", 
    from_= " +15017250604, replace it with your Twilio phone Number,twilio assigned to you,
    body= "Hello from Python twilio!")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.