Twilio 可用电话搜索前缀 [英] Twilio available phone search by prefix
问题描述
如何使用 API 按前缀搜索电话号码?Twilio购买号码"工具可让您搜索以术语开头的内容,但我看不到使用 API 进行搜索的方法.
How do I search for phone number by prefix using the API? The Twilio "Buy A Number" tool lets you search for begins with term, but I don't see a way to do it using the API.
你可以这样做:
AvailablePhoneNumbers/US/Local?Contains=703%
但这仍然可以在任何地方找到带有 703 的数字,而不仅仅是前缀.我能看到的唯一方法是使用 * 单号搜索,a la:
But that still finds numbers with 703 anywhere, not just the prefix. Only way I can see to do this is using the * single number search, a la:
AvailablePhoneNumbers/US/Local?Contains=703*******
但是,我如何将其通用化到任何国家/地区?有每个国家/地区电话号码长度的查找表,以便我可以添加适当数量的 *?
But then how do I make that generic to any country? Have a lookup table of phone number lengths for every country so I can add the appropriate number of *'s?
推荐答案
Twilio 在其 API 文档 (按号码模式查找电话号码).
Twilio provides this information in their API docs (Find phone numbers by number pattern).
例如使用PHP:
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACde6f132a3c49700934481addd5ce1659";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
$numbers = $client->account->available_phone_numbers->getList('US', 'Local', array(
"Contains" => "510555****"
));
foreach($numbers->available_phone_numbers as $number) {
echo $number->phone_number;
}
这篇关于Twilio 可用电话搜索前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!