转自:https://cuiqingcai.com/5696.html

个人验证短信发送成功,但是电话拨打未成功(待进一步探索),代码如下(前期安装注册见上述链接):

from twilio.rest import Client


def Send_Message(): 
    account_sid = '..................'   # 注册后得到
    auth_token = '...................'   # 注册后得到
    client = Client(account_sid, auth_token)
    message = client.messages.create(
        to="+86***********",  # 缺点是收信人必须要先认证
        from_="***********",  #官网注册后得到的一个手机号码
        body="来了老弟")  #短息内容
    #print(message.sid)


def Phone_Call():
    account_sid = '..........................'  
    auth_token = '...........................'
    client = Client(account_sid, auth_token)
    call = client.calls.create(
        to="+***********",
        from_='***********',  # 官网注册后得到的一个手机号码
        url="http://demo.twilio.com/docs/voice.xml",
        method="GET",
        status_callback="https://www.myapp.com/events",
        status_callback_method="POST",
        status_callback_event=["initiated", "ringing", "answered", "completed"]
    )
    print(call.sid)

if __name__ == "__main__":
    Send_Message()
    #Phone_Call()

短信如下发送成功

利用python库twilio来免费发送短信

相关文章:

  • 2021-12-05
  • 2022-01-16
  • 2022-12-23
  • 2021-11-29
  • 2021-12-08
  • 2021-12-18
  • 2022-12-23
  • 2021-08-19
猜你喜欢
  • 2022-02-19
  • 2021-06-12
  • 2021-08-18
  • 2021-09-14
  • 2022-12-23
相关资源
相似解决方案