public function actionCall() { require_once 'protected/extensions/Twilio/Twilio.php'; //Yii::import('application.vendor.autoload'); // Twilio REST API version $version = "2016-02-25"; // Set our Account SID and AuthToken $sid = 'AC6f2b9944225754e4914282b1be9da523'; $token = '3d58e80ae1d3c4d7049c238c511b987a'; // A phone number you have previously validated with Twilio $phonenumber = '353867964180'; // Instantiate a new Twilio Rest Client $client = new Services_Twilio($sid, $token, $version); try { // Initiate a new outbound call $call = $client->account->calls->create($phonenumber, '37494471018', 'http://demo.twilio.com/welcome/voice/', array('Method' => 'POST')); echo 'Started call: ' . $call->sid; } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); echo '<br>'; echo 'Error: ' . $e->getStatus(); } if (Yii::app()->getRequest()->getIsPostRequest()) { $phone = Yii::app()->getRequest()->getParam('phone'); ActionClass::out($phone); } return $this->redirect($_SERVER['HTTP_REFERER']); }