python - 如果您在购买 twilio 号码时未捕获它,请稍后获取 twilio 电话号码 SID
问题描述
如果您在购买 twilio 号码时没有捕获它,是否有任何简单的方法可以在以后获取电话号码 SID。
购买号码时很容易捕获电话号码 sid,但我发现以后捕获它的解决方案似乎很复杂并且使用循环。
购买号码时捕获电话号码 SID:
from twilio.rest import Client
account_sid = 'accountsid'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
# Purchase the phone number
number = client.incoming_phone_numbers \
.create(phone_number=number)
print(number.sid)
解决方案
您可以使用“完全匹配”进行过滤。
例如,如果您的号码是+17775553333
,请尝试使用此代码获取sid
。
from twilio.rest import Client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
incoming_phone_numbers = client.incoming_phone_numbers.list(phone_number='+17775553333', limit=20)
for record in incoming_phone_numbers:
print(record.sid)
推荐阅读
- django - Django - 在为帐户类型创建用户期间使用 Profile 模型扩展用户
- excel - 如何在 Phpspreadsheet 中获取工作表 2?
- java - 正则表达式模式中不正确的嵌套括号
- python - word2vec 模型类(Python)
- filemaker - 文件制作者问题。我需要从三个表的数据集中创建一个表
- woocommerce - 在 WooCommerce 中向自定义分类添加自定义字段
- spring - 启用全局 Spring 异常处理程序时忽略给定列表中的失败数据
- android - 如何打开热点和网络共享设置屏幕,然后以编程方式打开安全弹出屏幕?
- node.js - 进行 e2e 测试时如何正确运行我的应用程序?
- jboss - java.lang.VerifyError: org/jboss/remoting3/remote/HttpUpgradeConnectionProvider