python中Twilio短信发送方api

2024-04-18 13:54:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码:

from twilio.rest import Client

# Find these values at https://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

client.api.account.messages.create(
    to="+#############",
    from_="+###########",
    body="Hello there!")

我得到的错误是:

^{pr2}$

我想尽一切办法来制作SID和身份验证令牌based on this link,但我无法向我的手机发送任何短信


Tags: 代码fromimportclienttokenauthrestaccount
1条回答
网友
1楼 · 发布于 2024-04-18 13:54:27

Twilio开发者布道者。在

响应中有一个URL可以帮助解释发生了什么。可悲的是,它似乎在日志中有些混乱。在

我的建议是你抓住错误,试着用另一种方法打印出来。试试这个,看看结果如何:

client = Client(account_sid, auth_token)
try:
    client.api.account.messages.create(
        to="+#############",
        from_="+###########",
        body="Hello there!")
except TwilioRestException as ex:
    print(ex)

相关问题 更多 >