繁体   English   中英

使用 twilio python api 拨打电话时出错

[英]Getting error making calls with twilio python api

当我尝试使用 twilio python api 拨打电话时出现此错误:

Jacob-Mac-mini:downloads kovyjacob$ python3 twilio_call.py
Traceback (most recent call last):
  File "/Users/kovyjacob/Downloads/twilio_call.py", line 11, in <module>
    call = client.calls.create(
  File "/Users/kovyjacob/Library/Python/3.9/lib/python/site-packages/twilio/rest/api/v2010/account/call/__init__.py", line 141, in create
    payload = self._version.create(method='POST', uri=self._uri, data=data, )
  File "/Users/kovyjacob/Library/Python/3.9/lib/python/site-packages/twilio/base/version.py", line 205, in create
    raise self.exception(method, uri, response, 'Unable to create record')
twilio.base.exceptions.TwilioRestException: 
HTTP Error Your request was:

POST /Accounts/['AC766eaf7ef8d79de658756223cee446df']/Calls.json

Twilio returned the following information:

Unable to create record: The requested resource /2010-04-01/Accounts/['AC766eaf7ef8d79de658756223cee446df']/Calls.json was not found

More information may be available here:

https://www.twilio.com/docs/errors/20404

我检查了链接,但是 a)我不确定问题到底是什么,并且 b)它没有说明如何解决它。

这是代码:

from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ['AC766eaf7ef8d79de658756223cee446df']
auth_token = ['74ef4743a7a9a748cxxxxxxxxxxxxxxx']
client = Client(account_sid, auth_token)

call = client.calls.create(
                        twiml='<Response><Say>Ahoy, World!</Say></Response>',
                        to='+14372341004',
                        from_='+14243560675'
                    )

print(call.sid)

account_sidauth_token应该作为字符串传递,而不是内部包含字符串的数组。

Twillio Rest 客户端源代码

将您的代码编辑为:

account_sid = 'AC766eaf7ef8d79de658756223cee446df'
auth_token = '74ef4743a7a9a748cxxxxxxxxxxxxxxx'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM