Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to send free text messages to your girlfriend every day

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how to use Python to send free text messages to my girlfriend every day. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Preface

Today's tutorial is to teach you how to send free text messages to your girlfriend.

I know that there are two common platforms for sending SMS messages, one is twilio, which can send 500 free SMS messages or any message, and the other is Tencent Cloud, which can send 100 SMS messages for free. You need to apply for a template for sending SMS messages.

In view of the fact that twilio is a little more free, this time we will send the weather information to our parents by twilio.

Twilio registration

To send text messages, we need to register an account on twilio's official website now.

Https://www.twilio.com/

Click Sign Up to register an account.

Fill in the mailbox, password and other information, after submission, there will be a verification to determine whether it is a robot, click the left and right arrow to make the pattern display as a positive picture.

Then go to the mailbox you just filled in to verify, you need to fill in the mobile phone number for verification.

At the beginning, I used the mobile number and sent it twice without receiving the CAPTCHA. I don't know why, but then I received the CAPTCHA after changing the telecom.

After successful verification, you will be prompted to select whether to call through the code.

Select yes and then choose the corresponding language, of course, we choose Python.

Get the trial number

After selecting the use, you can get a trial number, click the Get a Trial Number button.

We can see the number provided to me by the system.

Click OK and the successful page will appear, showing the number provided by Twilio, which is used to send text messages.

After obtaining the number, it automatically jumps back to the home page. Below is an example of Python calling SMS API.

After entering the API call instructions, we see an example of sending text messages directly by the API Python on the right.

We can just use it and replace the account_sid and auth_token in the code with our own. These two values are shown on the page of the number just now.

Then replace the body in message with your own text, and change the number of the message sent to the official number.

Receiving number verification

Before using the receiving number, you need to verify it on Twilio, click verified numbers on the right to enter and add the number.

Since this is a free version, only one number is supported. If there is a verification number before, we need to click the X on the right to delete the number in order to add a new number.

After clicking the button to verify the number, select the text you instead on the lower left of the pop-up page, that is, use the SMS verification code to verify the newly added number, you need to send it to your girlfriend, of course, the received number is filled in your girlfriend's.

After filling in the number, click verify and wait for the CAPTCHA.

I tried the mobile number, the Unicom number and the electric signal respectively, and found that the electric signal and the Unicom card could receive the verification code normally, but the mobile number could not receive the verification code several times. There is a balance in the card. Maybe the mobile card does not support this interface. You can try it.

Code debugging

Don't forget to install the twilio library with the pip command before running the code.

Pip install twilio

Then replace several values in the code with your own.

Add the number that has just been verified to the code, run the code, and you will receive the text message after success.

Then we send out the previous weather information by text message, of course you can send other information. Here I use the previous weather information in order to be lazy.

Wechat related to the previous code is removed, and the weather interface is partially retained.

Change the key into your own. For more information, please see this article. Make a weather warning assistant for your parents when the weather gets cold.

Replace the content of the text message you just sent with the message msg returned by the weather API, and the code for timing operation is the same as before.

The effect of running the code is as follows:

Similarly, I still put the program on the server, and I will continue to send the weather information for the day at the same time the next day. I set it at an interval of 24 hours, of course, you can change the interval.

After reading the above, do you have any further understanding of how to use Python to send free text messages to your girlfriend every day? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 251

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report