Twilio文档提供了一个搜索在美国搜索本地号码的数字的示例。
$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;
}
有没有办法让所有可以获得twilio数字的国家?所以我可以在其中一个国家搜索一个号码。 感谢
答案 0 :(得分:2)
我设法获得了可以获得twilio数字的国家/地区列表
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();
}
}
答案 1 :(得分:2)
列出具有语音服务的国家/地区
https://www.twilio.com/docs/api/pricing/voice#list
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC324da90614bccf7f52759757713463c0";
$token = "your_auth_token";
$client = new Client($sid, $token);
$voiceCountries = $client->pricing->voice->countries->read();
foreach ($voiceCountries as $c) {
echo $c->isoCountry . PHP_EOL;
}
列出具有邮件服务的国家/地区
https://www.twilio.com/docs/api/pricing/messaging#list
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC324da90614bccf7f52759757713463c0";
$token = "your_auth_token";
$client = new Client($sid, $token);
$messagingCountries = $client->pricing->messaging->countries->stream();
foreach ($messagingCountries as $c) {
echo $c->isoCountry;
}
列出具有Twilio数字的国家/地区
https://www.twilio.com/docs/api/pricing/phonenumbers#list
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC324da90614bccf7f52759757713463c0";
$token = "your_auth_token";
$client = new Client($sid, $token);
$phoneNumberCountries = $client->pricing->phoneNumbers->countries->read();
foreach ($phoneNumberCountries as $c) {
echo $c->isoCountry . PHP_EOL;
}