Lame opening remarks

At the end of the last Python check-in, we asked if there was a way to send out the results of the check-in, and that’s where we found Twilio.

This article is supported by “One Companion Editor”

Twilio is a California-based cloud communications (PaaS) company that provides developers with an API for communication modules. Since Twilio provides free phone and SMS service for trial accounts, we can use Twilio to receive verification SMS online in real time when applying for foreign free resources requiring verification SMS.

Below, we will introduce the application and SMS sending process of Twilio in detail.

1Registration and Setup

Visit http://twilio.com/ and fill out the registration form. Once you sign up for a new account, you need to verify a mobile phone number and a text message will be sent to that number. You also need to do a man-machine verification to prove that you are a person!

After successful registration, you need to create a Project. After entering the Project interface, you can see SID and TOKEN information, which will be used in the following code:

Project

You need to activate a phone number, ask Twilio to assign one, and then use it to send text messages. In the Project page under Phone Numbers:

Get the number

To send a text message using a Twilio number, you need to verify the recipient’s mobile phone number. On the Phone Numbers TAB, select Verified Caller IDs. On the number verification page, select SMS authentication.

Validation of 1

Verify the 2

Verify the 3

Enter the mobile phone verification code. After confirmation, the recipient’s mobile phone verification is completed.

In fact, the whole process is a bit cumbersome, there are uncertain can refer to the method of the net to do, or directly ask hungry oh.

Now, we can use the code to send the message.

2use

First, to install, also very simple:

pip install twilio

Copy the code

The official Documentation for Twilio provides various ways to send text messages using code such as Python:

Here, the trial account that Twilio needs to provide includes a phone number that will act as the sender of the text message. Two more pieces of information are required: your account SID and TOKEN. In Python, these values will act as your Twilio username and password.

In addition, the mobile phone number of TO must be verified!

  • Sending effect:

Send the effect

Doesn’t look bad. Maybe because it is a trial account, there are some words of Twilio trial. Maybe where to set can be removed, interested can study.

3 integration

Last time, we said whether there is a way to remind the check-in success in the food line, now you can operate.

Define a function to send an SMS message to the specified number:

Complete code background reply “food line fresh” can be obtained.

conclusion

Twilio is easy to use, and the official documentation is great, providing sample code. Here we only demonstrated the function of sending SMS, interested can also try receiving SMS, call and other functions.

If the Twilio registration process is confusing, check out http://uuxn.com/twilio-toll-free-sms

This article is supported by “One Companion Editor”

welfare
For class network

This article is supported by “One Companion Editor”

Share my Python learning resources

Python crawler Entry (Level 3)

Teach you to read web pages in Python

Python crawls “Planet of Knowledge”

Are you still using format to format strings?

Python to spin the Excel