Question

In my project I need to develop an autocomplete in order to allow users to search and reserve Twilio Toll-Free phone numbers.

Well, it's not a problem to communicate with Twilio REST API for me, but it makes me crazy since it works in quite strange manner. So, initially I have got some string, part of phone number, and I need to get all those numbers which contain that string.

As described here, I use Contains parameter to provide the keyword to Twilio. Twilio returns me different numbers, but none of them really contain the keyword.

You can say that I did not read the documentation carefully, and for got to append '*' character to my keyword. I tried to append them, but result is the same. I can not logically explain why I get not those numbers which I request. The only possible theory - Twilio compares the keyword not against the phone number itself, and against some other it's property.

Twilio developers, evangelists, please share your suggestions - What am I doing wrong? It a very simple task. Is it impossible to implement normal phone numbers search with Twilio API?

$search = array('InPostalCode' => '', 'NearNumber' => '', 'contains' => '888******');
$numbers = $twilio->account->available_phone_numbers->getList('US', 'TollFree', $search);
Was it helpful?

Solution

Twilio evangelist here.

Change the 'contains' parameter to 'Contains' (upper case 'C'). The API is case sensitive.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top