使用python代码给手机发短信详解(twilio的使用)

在这里插入图片描述

使用python代码给手机发短信详解


使用python代码给手机发送短信,在这里给大家推荐一个比较好的免费网站 twilio网页申请
下面给大家介绍一下使用及申请的步骤:

twilio网页注册

首先点击下面的网页进入官网进行注册twilio网页注册
进入网页后填写我们的信息即可生成一个随机号码及
account_sid

auth_token
这三个二东西到时候会在程序中用到,所以大家最好记下来。

实现代码

from twilio.rest import Client
# Your Account SID from twilio.com/console
account_sid = "替换成你的ACCOUNT_SID"
# Your Auth Token from twilio.com/console
auth_token  = "替换成你的auth_token"
client = Client(account_sid, auth_token)
message = client.messages.create(
    to="+86xxxxxxxxxxx", #填写你注册时候的手机号,也就是用于接收信息的手机号
    from_="+***********,替换成你的twilio phone number,twilio分配给你的",
    body="我在twilio中给你发送短信,测试成功")

效果演示

在这里插入图片描述

以上就是全部内容,希望对有所帮助!

在这里插入图片描述

发布了40 篇原创文章 · 获赞 41 · 访问量 5919

猜你喜欢

转载自blog.csdn.net/qq_45172832/article/details/104474222