利用python库twilio来免费发送短信和打电话 |
您所在的位置:网站首页 › python拨打网络电话 › 利用python库twilio来免费发送短信和打电话 |
1 注册
1.1登录twilio网站
1.2 注册流程:
(1)点击Console进入Dashboard: 以下建立一个python测试实例:send_message.py 1 from twilio.rest import Client 2 3 # Your Account Sid and Auth Token from twilio.com/console 4 # DANGER! This is insecure. See http://twil.io/secure 5 account_sid = 'AC86e51a7ca381111fe72afdf1111e1d53' 6 auth_token = '9a66b1111a3bc7f1f48cf78a11113468' 7 client = Client(account_sid, auth_token) 8 9 message = clienssages \ 10 .create( 11 body="Attention! Tomorrow will be rain!!!", 12 from_='+13343263412', # 此手机号码由twilio分配,用于发短信 13 to='+8615077906553' # 此号码用于接收短信,测试账号必须是平台验证过的手机号码,否则异常! 14 ) 15 16 print(message.sid) # 发送成功会得到以“SM”开头的短信ID字符串,如:SM321bd9bca40c41c28fb34e269cd18dbc运行: python send_message.py输出: SM21a0f07f93db4ad28377adb262938e34 Twilior 语音实例Twilio语音python代码文档: # Download the helper library from https://www.twilio.com/docs/python/install from twilio.rest import Client # Your Account Sid and Auth Token from twilio.com/console # DANGER! This is insecure. See http://twil.io/secure account_sid = 'ACa9c996fb0574202fec92beb9f7965e56' auth_token = 'your_auth_token' client = Client(account_sid, auth_token) call = client.calls.create( url='http://demo.twilio.com/docs/voice.xml', to='+15558675310', from_='+15017122661' ) print(call.sid) |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |