python 发短信

内容来自文心一言

pip install twilio

from twilio.rest import Client

# 从Twilio网站获取以下信息
account_sid = ‘YOUR_ACCOUNT_SID’
auth_token = ‘YOUR_AUTH_TOKEN’
twilio_phone_number = ‘YOUR_TWILIO_PHONE_NUMBER’
destination_phone_number = ‘DESTINATION_PHONE_NUMBER’

# 创建Twilio客户端对象
client = Client(account_sid, auth_token)

# 发送短信
message = client.messages
.create(
body=”Hello, World!”, # 短信正文
from_=twilio_phone_number, # 发送短信的Twilio电话号码
to=destination_phone_number # 接收短信的目标电话号码
)

# 打印消息SID
print(message.sid)

You may also like...

发表回复