Issue
Twilio documentation provides one example of searching numbers where they search for local numbers in US.
$client = new Services_Twilio($sid, $token);
$numbers = $client->account->available_phone_numbers->getList('US', 'Local', array(
"InRegion" => "AR"
));
foreach($numbers->available_phone_numbers as $number) {
echo $number->phone_number;
}
Is there a way I can get all the countries where twilio numbers are available ? So I can search a number in one of those countries. Thanks
Solution
I managed to get the list of countries where twilio numbers are available
public function getAvailableCountries(){
$client = new \Services_Twilio($this->sid, $this->token);
$uri = '/'. $client->getVersion() . '/Accounts/' . $this->sid . '/AvailablePhoneNumbers.json';
try{
$numbers = $client->retrieveData($uri);
//returns an array of countries where twilio numbers are supported
return $numbers->countries;
}catch(Exception $e){
return $e->getMessage();
}
}
Answered By - Ashfaq Ahmed Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.