Twilio查找测试数字

时间:2016-07-06 20:41:49

标签: twilio twilio-api

There are test numbers您可以使用my test credentials向其发送短信。他们假装发送很漂亮。但是,尝试使用Twilio提供的lookup API,即使打算检索有关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是唯一可以模拟固定电话的电话号码,无法返回短信。我期待API为此类号码返回运营商类型的“固定电话”。 That link in the error message将我带到一个没有可用测试凭据的页面。

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

1 个答案:

答案 0 :(得分:4)

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

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

“支持的资源

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

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

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

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

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