【发布时间】:2020-09-16 00:06:08
【问题描述】:
我想通过 Twilio 模块使用 python 发送 whatsapp 消息。我从 youtube 获得了一个代码,当运行代码时,它出现了一个错误
Traceback (most recent call last):
File "whatsapp.py", line 4, in <module>
client = Client()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\twilio\rest\__init__.py", line
54, in __init__
raise TwilioException("Credentials are required to create a TwilioClient")
twilio.base.exceptions.TwilioException: Credentials are required to create a TwilioClient
这是我的代码:
from twilio.rest import Client
client = Client()
from_whatsapp_number = 'whatsapp: +60***86744'
to_whatsapp_number = 'whatsapp: +8134***727'
client.messages.create(body='Testing message using python',
from_ = from_whatsapp_number,
to = to_whatsapp_number)
【问题讨论】:
-
Twilio 想要您的“API 密钥”或客户端 ID。
-
如果您将客户端参数留空,则假定您在您的环境中配置了帐户 SID 和身份验证令牌 - twilio.com/docs/libraries/reference/twilio-python/index.html
标签: python twilio message whatsapp