How to automatically send text messages to girlfriend

"How to automatically send text messages to girlfriend via mobile phone"

In the previous time, we can automatically send messages to the girlfriend through WeChat to make the girlfriend very happy, and the female partner is very happy with the messages you send in the past every day. What do we want to do if we want to send a text message to the girlfriend through the mobile phone number?

01—The cause of the incident

The cause of the incident was because we were lazy through WeChat and we were found out by our girlfriend. She was very angry about your actions. She made a request to you and asked you to send messages to her via SMS every day, so she would forgive you.

Once you listen, it's over, " Let's learn programming together " hasn't taught us to send messages through mobile phone numbers! This is how to do? Don't worry, I will tell you right away.

02—Programming realization

As the saying goes, Python can do everything except not having children. The ancients once said: Things that can be solved in one language are absolutely unnecessary in two languages.

Ahem, digress...

Beforehand, we need to import a module.

pip  install twilio

This is what we are going to use.

Then look at the specific code:

from twilio.rest import Client

# 下面认证信息的值在你的 twilio 账户里可以找到
account_sid = ""
auth_token = ""
body="填写你所需要的消息内容!"
client = Client(account_sid, auth_token)

message = client.messages.create(to="+86+手机号码",  # 区号+你的手机号码
                                 from_="+15617817891",  # 你的 twilio 电话号码
                                 body=body)
print("发送成功")

Is the code very simple.

Here you need to get the sid and auth_token. I provide the official website here. You can apply for one yourself.

https://www.twilio.com/try-twilio

Then we are here to add time and send it at 8:00 every day.

 

from twilio.rest import Client
import time

def message():
    # 下面认证信息的值在你的 twilio 账户里可以找到
    account_sid = ""
    auth_token = ""
    body="填写你所需要的消息内容!"
    client = Client(account_sid, auth_token)
    client.messages.create(to="+86+手机号码",  # 区号+你的手机号码
                                     from_="+15617817891",  # 你的 twilio 电话号码
                                     body=body)
    print("发送成功")
def time_1():
    while True:
        time.sleep(3600)#设置等待时间。
        t=time.strftime("%H:%M:%S", time.localtime())#08:00:00
        if t=="08:00:00":
            message()
if __name__=="__main__":
    time_1()

 

So far, the purpose of automatically sending messages every day has been achieved.

related suggestion:

                     There is a barrage in the sky—the desktop version of barrage. Check it out.

                     How to make a girlfriend smile---accompany the confession robot

                    You can control the computer by sending commands through your mobile phone. Check it out!

                    Build your own voice chat robot

                    Automatic operation of the browser-no interface selenium crawler

                    WeChat add friends automatically

                    The romance that programmers understand

Like articles full of science and technology, follow the official account to learn more.

Guess you like

Origin blog.csdn.net/qq_39046854/article/details/84934156