2016-03-31 8 views

答えて

0

Twilioの開発者エバンジェリストをありがとうございました。

Twilio APIを使用して新しい電話番号をプロビジョニングするには、2段階のプロセスが必要です。まず、Available Phone Numbers resourceを使用して利用可能な電話番号を見つける必要があります。 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 = "{{ account_sid }}"; 
$token = "{{ auth_token }}"; 
$client = new Services_Twilio($sid, $token); 

$numbers = $client->account->available_phone_numbers->getList('US', 'Local'); 
foreach($numbers->available_phone_numbers as $number) { 
    echo $number->phone_number; 
} 

次に、request to the Incoming Phone Numbers resource to purchase that numberを作成する必要があります。

// choose $twilio_number from the previous response. 
$number = $client->account->incoming_phone_numbers->create(array(
    "FriendlyName" => "My Company Line", 
    "VoiceUrl" => "http://demo.twilio.com/docs/voice.xml", 
    "PhoneNumber" => $twilio_number 
)); 

Incoming Phone Numbers instance resourceを使用して番号を更新できます。

それがまったく役に立ったら教えてください。

+0

ありがとうございますphilnash =) – Drex

関連する問題