twilio注册地址 注册的时候可能会报错 最好是科学上网 -->注册-->注册完毕后代码运行是不需要科学上网的
https://www.twilio.com/console
需要pip3 install twilio模块
如果你想收到短信的话必须进行对你的号码进行授权 会给你发验证码
视频资料:https://www.youtube.com/watch?v=knxlmCVFAZI
文档资料:https://www.twilio.com/docs/sms/quickstart/python
短信日志:https://www.twilio.com/console/sms/logs?startDate=2018-11-01+00%3A00%3A00&endDate=2018-11-30+23%3A59%3A59
先来2段代码
#代码1 from twilio.rest import Client account = 'AC8b1d590dc7eadf8dd7d14515d0ed6481'
token = '2f13f71946cf38cbd9c22a80d7819e14'
myNumber = '+86186XXXXXXXX'
twilioNumber = '+19797303542' def textmyself(message):
client = Client(account, token)
message = client.messages.create(to=myNumber, from_=twilioNumber,body=message)
textmyself('This is twilio message from 172.20.59.127') #代码2
from twilio.rest import Client
accountSID='AC8b1d590dc7eadf8dd7d14515d0ed6481'
authToken='2f13f71946cf38cbd9c22a80d7819e14'
twilioCli = Client(accountSID, authToken)
myTwilioNumber='+19797303542'
myCellPhone='+86XXXXXXXX'
message = twilioCli.messages.create(body='172.20.59.127', from_=myTwilioNumber, to=myCellPhone)
目前问题在于不能发送中文 还有每次发送的号码存在不一致的问题
注意一个问题 发送多了 容易阻塞 免费版就这样
升级轰炸机版本
from twilio.rest import Client
from threading import Timer
import time
current_time=time.ctime()
account = 'AC8b1d590dc7eadf8dd7d14515d0ed6481'
token = '2f13f71946cf38cbd9c22a80d7819e14'
myNumber = '+86139XXXXXXXX' twilioNumber = '+19797303542'
message='This is nodchen from 172.20.59.127'
print(message)
def textmyself():
client = Client(account, token)
client.messages.create(to=myNumber, from_=twilioNumber,body=message)
t = Timer(60, textmyself)
t.start()
if __name__ == "__main__":
textmyself()