非美国 (US1) 通话的 Twilio 通话费用? (例如IE1调用)

问题描述 投票:0回答:1

我正在尝试通过 Call SID 获取 Twilio 上的通话费用。

这是我的代码:

account_sid = 'my_sid'
auth_token = 'my_us1_token' or 'my_ie1_token'
call_sid = 'a_call_sid_from_us1_region' or 'a_call_sid_from_ie1_region'

client = Client(account_sid, auth_token)
call = client.calls(call_sid).fetch()
print(f"Price: {call.price} {call.price_unit}")

当我将“my_us1_token”和“a_call_sid_from_us1_region”放在一起时,一切正常。我得到这样的东西:

价格:-0.01000 美元

如果我将“my_ie1_token”与“a_call_sid_from_ie1_region”一起使用,我会在代码行上收到以下错误:“call = client.calls(call_sid).fetch()”

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twilio/rest/api/v2010/account/call/__init__.py", line 392, in fetch
    payload = self._version.fetch(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twilio/base/version.py", line 141, in fetch
    return self._parse_fetch(method, uri, response)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twilio/base/version.py", line 112, in _parse_fetch
    raise self.exception(method, uri, response, "Unable to fetch record")
twilio.base.exceptions.TwilioRestException: 
HTTP Error Your request was:

GET /Accounts/ACxxxxxxxxxxxxxx/Calls/CAxxxxxxxxxxxxxxxxx.json

Twilio returned the following information:

Unable to fetch record: The requested resource /2010-04-01/Accounts/ACxxxxxxxxxxx4/Calls/CAxxxxxxxxxxx.json was not found

More information may be available here:

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

知道如何解决这个问题吗?似乎是 Twilio 方面的一个错误 :( 但只是为了确定......

谢谢。

twilio twilio-api twilio-twiml twilio-php
1个回答
0
投票

回答我的问题:

非美国地区需在客户端指定:

client = Client(
  settings.TWILIO_ACCOUNT_SID,
  settings.TWILIO_AUTH_TOKEN,
  region='ie1',
  edge='dublin'
)

参见:https://github.com/twilio/twilio-python#specify-region-andor-edge

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.