Twilio 查找测试编号

Twilio lookup test numbers

There are test numbers to which you can send SMS using my test credentials. They fake sending beautifully. But, attempting to use the lookup API also provided by Twilio, even if the intention is to retrieve information about the test number,会失败:

>>> from django.conf import settings
>>> from twilio.rest.lookups import TwilioLookupsClient
>>> account_sid = settings.TWILIO_ACCOUNT_SID
>>> auth_token = settings.TWILIO_AUTH_TOKEN
>>> client = TwilioLookupsClient(account_sid, auth_token)
>>> lookup_client.phone_numbers.get('+15005555009', include_carrier_info=True)
---------------------------------------------------------------------------
TwilioRestException                       Traceback (most recent call last)
<ipython-input-9-03718f1c0615> in <module>()
----> 1 client.phone_numbers.get('+15005555009', include_carrier_info=True)

...

TwilioRestException: 
HTTP Error Your request was:

GET https://lookups.twilio.com/v1/PhoneNumbers/+15005555009?Type=carrier

Twilio returned the following information:

Resource not accessible with Test Account Credentials

More information may be available here:

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

+15005555009 是唯一列出的模拟固定电话的 phone 号码,无法 return 发送短信。我期待 API 到 return 'landline' 对于这样一个数字的运营商类型。 That link in the error message 将我带到一个没有有效测试凭据的页面。

如何使用给定的测试凭据测试查找 API?

我认为您不能将查找 API 与测试凭据一起使用。

来自 https://www.twilio.com/docs/api/rest/test-credentials ...

“支持的资源

您的测试凭据当前可用于与以下三种资源交互:

  • 购买phone号码:POST /2010-04-01/Accounts/{TestAccountSid}/IncomingPhoneNumbers

  • 正在发送短信:POST /2010-04-01/Accounts/{TestAccountSid}/SMS/Messages

  • 拨打电话:POST /2010-04-01/Accounts/{TestAccountSid}/Calls

对具有测试凭据的任何其他资源的请求将收到 403 禁止响应。将来,我们也可能启用这些资源进行测试。"