Example #1
0
 public function addTwilioNumber()
 {
     // Get Twilio Phone
     // Initiate Twilio
     $sid = Yii::$app->params['twilioId'];
     $token = Yii::$app->params['twilioToken'];
     $client = new Twilio\Rest\Client($sid, $token);
     $numbers = $client->availablePhoneNumbers('US')->local->read(["areaCode" => "561"]);
     // Purchase the first number on the list.
     $number = $client->incomingPhoneNumbers->create(["phoneNumber" => $numbers[0]->phoneNumber, 'FriendlyName' => 'Project - ' . $this->title, 'SmsUrl' => 'http://portal.frontrunnercasting.com/message/incoming/' . $this->id, 'SmsMethod' => 'POST', 'Capabilities' => ['SMS' => true]]);
     $this->twilio_number = $numbers[0]->phoneNumber;
     $this->save();
 }
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->local->read(array("nearLatLong" => "37.840699,-122.461853", "distance" => "50", "contains" => "555", "inRegion" => "CA"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('GB')->local->read(array("voiceEnabled" => "true"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('GB')->local->read(array("contains" => "4420"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('GB')->mobile->read();
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->local->read(array("excludeLocalAddressRequired" => "true"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->local->read(array("contains" => "STORM"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->tollFree->read();
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->tollFree->read(array("contains" => "KYLO", "areaCode" => "800"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->local->read(array("areaCode" => "510"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;
<?php

// 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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$numbers = $client->availablePhoneNumbers('US')->local->read(array("inRegion" => "AR"));
// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers->create(array("phoneNumber" => $numbers[0]->phoneNumber));
echo $number->sid;