예제 #1
0
파일: 45.php 프로젝트: JeffaCubed/OpenVBX
function runUpdate_45()
{
    set_time_limit(3600);
    $ci =& get_instance();
    $tenants = $ci->db->from('tenants')->get()->result();
    $ci->load->model('vbx_incoming_numbers');
    $numbers = $ci->vbx_incoming_numbers->get_numbers($retrieve_sandbox = true);
    foreach ($tenants as $tenant) {
        error_log("Updating to 2010: " . var_export($tenant, true));
        $twilio_sid = $ci->settings->get('twilio_sid', $tenant->id);
        $twilio_token = $ci->settings->get('twilio_token', $tenant->id);
        $twilio = new TwilioRestClient($twilio_sid, $twilio_token, 'https://api.twilio.com/2010-04-01');
        $response = $twilio->request("Accounts/{$twilio_sid}/IncomingPhoneNumbers");
        $numberUrls = array();
        if (isset($response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber)) {
            $xmlPhoneNumbers = $response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber ? $response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber : array($response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber);
            foreach ($xmlPhoneNumbers as $number) {
                $numberUrls[] = preg_replace('#/20[0-9]{2}-\\d{2}-\\d{2}/#', '', (string) $number->Uri);
            }
        }
        foreach ($numberUrls as $url) {
            error_log("updating {$url}");
            $response = $twilio->request($url, 'POST', array('ApiVersion' => '2010-04-01'));
        }
    }
    $ci->settings->set('schema-version', '45', 1);
}
예제 #2
0
 public static function createTextResponse(BlastResponse $response)
 {
     $user = $response->getUser();
     Utils::logNotice('Sending text response for ' . $response->getBlast()->getMinyan()->getName() . ' to ' . $response->getUser()->getFullname() . ' (' . $response->getUser()->getPhone() . ')');
     $data = array("From" => sfConfig::get("app_twilio_caller_id"), "To" => "1" . $user->getPhone(), "Body" => $response->getBlast()->getTextMessage());
     $client = new TwilioRestClient(sfConfig::get("app_twilio_sid"), sfConfig::get("app_twilio_auth_token"));
     $urlPrefix = "/" . sfConfig::get("app_twilio_api_version") . "/Accounts/" . sfConfig::get("app_twilio_sid") . "/";
     $client->request($urlPrefix . "SMS/Messages", "POST", $data);
 }
예제 #3
0
 function sms($body)
 {
     $twilio = new TwilioRestClient(get_option('wpc2c_twilio_sid'), get_option('wpc2c_twilio_token'), 'https://api.twilio.com/2008-08-01');
     $response = $twilio->request("Accounts/" . get_option('wpc2c_twilio_sid') . "/SMS/Messages", 'POST', array("From" => get_option('wpc2c_caller_id'), "To" => get_option('wpc2c_primary_phone'), "Body" => $body));
     $data = array('error' => false, 'message' => '');
     if ($response->IsError) {
         $data['error'] = true;
         $data['message'] = $response->ErrorMessage;
     }
     echo json_encode($data);
 }
예제 #4
0
 public static function get_all_twilio_numbers()
 {
     global $ApiVersion, $AccountSid, $AuthToken;
     $twilio_numbers = array();
     $client = new TwilioRestClient($AccountSid, $AuthToken);
     $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/IncomingPhoneNumbers", "GET");
     // Get all twilio phone numbers
     foreach ($response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber as $number) {
         $twilio_numbers[format_phone($number->PhoneNumber)] = $number->FriendlyName;
     }
     return $twilio_numbers;
 }
예제 #5
0
 function dial($number)
 {
     $twilio = new TwilioRestClient(get_option('wpc2c_twilio_sid'), get_option('wpc2c_twilio_token'), 'https://api.twilio.com/2008-08-01');
     $phone = get_option('wpc2c_primary_phone');
     $ext = get_option('wpc2c_primary_extension');
     $connecting_url = plugins_url('wp-click2call/wp-click2call.php?ext=' . urlencode($ext) . '&connect_to=' . urlencode($phone));
     $response = $twilio->request("Accounts/" . get_option('wpc2c_twilio_sid') . "/Calls", 'POST', array("Caller" => get_option('wpc2c_caller_id'), "Called" => $number, "Url" => $connecting_url));
     $data = array('error' => false, 'message' => '');
     if ($response->IsError) {
         $data['error'] = true;
         $data['message'] = $response->ErrorMessage;
     }
     echo json_encode($data);
 }
예제 #6
0
 function send_message($from, $to, $message)
 {
     $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
     error_log("Sending sms from {$from} to {$to} with content: {$message}");
     $response = $twilio->request("Accounts/{$this->twilio_sid}/SMS/Messages", 'POST', array("From" => $from, "To" => $to, "Body" => $message));
     $status = isset($response->ResponseXml) ? $response->ResponseXml->SMSMessage->Status : 'failed';
     if ($response->IsError || $status != 'sent' && $status != 'queued') {
         error_log("SMS not sent - Error Occurred");
         error_log($response->ErrorMessage);
         throw new VBX_Sms_messageException($response->ErrorMessage);
     }
 }
예제 #7
0
파일: 50.php 프로젝트: JeffaCubed/OpenVBX
function create_application($name, $tenant_id)
{
    $ci =& get_instance();
    $ci->load->model('vbx_settings');
    $appName = "OpenVBX :: {$name}";
    $twilio_sid = $ci->vbx_settings->get('twilio_sid', $tenant_id);
    $twilio_token = $ci->vbx_settings->get('twilio_token', $tenant_id);
    $twilio = new TwilioRestClient($twilio_sid, $twilio_token, 'https://api.twilio.com/2010-04-01');
    $response = $twilio->request("Accounts/{$twilio_sid}/Applications", 'GET', array('FriendlyName' => $appName));
    if ($response->IsError) {
        if ($response->HttpStatus > 400) {
            throw new Exception($response->ErrorMessage);
        }
    }
    // If we found an existing application, update the urls.
    $foundApp = intval($response->ResponseXml->Applications['total']);
    if ($foundApp) {
        $appSid = (string) $response->ResponseXml->Applications->Application->Sid;
        $response = $twilio->request("Accounts/{$twilio_sid}/Applications/{$appSid}", 'POST', array('FriendlyName' => $appName, 'VoiceUrl' => tenant_url('twiml/dial', $tenant_id), 'VoiceFallbackUrl' => asset_url('fallback/voice.php'), 'VoiceMethod' => 'POST', 'SmsUrl' => '', 'SmsFallbackUrl' => '', 'SmsMethod' => 'POST'));
        if ($response->IsError) {
            if ($response->HttpStatus > 400) {
                throw new Exception($response->ErrorMessage);
            }
        }
        // Otherwise, lets create a new application for openvbx
    } else {
        $response = $twilio->request("Accounts/{$twilio_sid}/Applications", 'POST', array('FriendlyName' => $appName, 'VoiceUrl' => tenant_url('twiml/dial', $tenant_id), 'VoiceFallbackUrl' => asset_url('fallback/voice.php'), 'VoiceMethod' => 'POST', 'SmsUrl' => '', 'SmsFallbackUrl' => '', 'SmsMethod' => 'POST'));
        if ($response->IsError) {
            if ($response->HttpStatus > 400) {
                throw new Exception($response->ErrorMessage);
            }
        }
        $appSid = (string) $response->ResponseXml->Application->Sid;
    }
    // Update the settings for this tenant
    $ci->vbx_settings->add('application_sid', $appSid, $tenant_id);
}
예제 #8
0
    $ok_emails = array();
    $isa = 0;
    foreach ($approved_list as $email) {
        //  echo $email;
        $tem['email'] = $email;
        $ok_emails[$isa++] = $tem;
    }
    $smarty->assign("ok_emails", $ok_emails);
}
// get the TWILIO credentials for the campaign creator
$res = $db->query("SELECT\r\nXE_TWI_ACCOUNT_SID AS ACCOUNT_SID,\r\nXE_TWI_AUTH_TOKEN AS AUTH_TOKEN\r\nFROM XEBURA_TWILIO_CREDENTIALS\r\nWHERE XE_TWI_MID = '" . $mid . "'");
$row = $db->fetchQueryArray($res);
$AccountSid = $row['ACCOUNT_SID'];
$AuthToken = $row['AUTH_TOKEN'];
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/OutgoingCallerIds", "GET", $data);
//print_r($response);
function convertXmlObjToArr($obj, &$arr)
{
    $children = $obj->children();
    foreach ($children as $elementName => $node) {
        $nextIdx = count($arr);
        //$arr[$nextIdx] = array();
        //$arr[$nextIdx]['@name'] = strtolower((string)$elementName);
        //$arr[$nextIdx]['@attributes'] = array();
        $attributes = $node->attributes();
        foreach ($attributes as $attributeName => $attributeValue) {
            $attribName = strtolower(trim((string) $attributeName));
            $attribVal = trim((string) $attributeValue);
            // $arr[$nextIdx]['@attributes'][$attribName] = $attribVal;
예제 #9
0
<?php

require_once 'include.php';
$client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Call the agent and put them in a conference room with the lead
$response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls', 'POST', array('From' => FROM_NUMBER, 'To' => AGENT, 'Url' => BASE_URL . 'conference.xml'));
header('Content-type: text/xml');
?>
<Response>
	<Say voice="woman">Please wait while I connect you.</Say>
	<Dial action="handle-hangup.php">
		<!-- Put the lead in a conference room -->
		<Conference>lead_connect</Conference>
	</Dial>
</Response>
예제 #10
0
require "phone-twilio.php";
require "includes/db_info.php";
// require POST request
if ($_SERVER['REQUEST_METHOD'] != "POST") {
    die;
}
// generate "random" 6-digit verification code
$code = rand(100000, 999999);
// save verification code in DB with phone number
// does not check for duplicates like it should
$number = mysql_real_escape_string($_POST["phone_number"]);
db(sprintf("INSERT INTO numbers (phone_number, verification_code) VALUES('%s', %d)", $number, $code));
mysql_close();
// initiate phone call via Twilio REST API
// Set our AccountSid and AuthToken
$AccountSid = "yourtwilioaccountsid";
$AuthToken = "yourtwilioauthtoken";
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// call data
$data = array("Caller" => "877-555-1212", "Called" => $number, "Url" => "http://example.com/twiml.php");
// make call
$response = $client->request("/2008-08-01/Accounts/{$AccountSid}/Calls", "POST", $data);
// error handling would go here
//if($response->IsError)
//	echo "Error starting phone call: {$response->ErrorMessage}\n";
// return verification code as JSON
$json = array();
$json["verification_code"] = $code;
header('Content-type: application/json');
echo json_encode($json);
//  if ($cellphone!=$in['recipient'])
//  {
// 	 echo "Error: Cellphone does not match $cellphone!=$in[recipient] for $in[id_customers]";
// 	 return;
// }
// 	echo "Finish $cellphone!=$in[recipient] for $in[id_customers]";
// 	return;
// Include the PHP TwilioRest library
require "twilio.php";
// Twilio REST API version
$ApiVersion = $in['twilio_apiversion'];
// Set our AccountSid and AuthToken
$AccountSid = $in['twilio_accountsid'];
$AuthToken = $in['twilio_authtoken'];
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// make an associative array of server admins
//     $people = array(
//         "7863038438"=>"Gabriel",
//     );
// Iterate over all our server admins
//     foreach ($people as $number => $name) {
// Send a new outgoinging SMS by POST'ing to the SMS resource */
// YYY-YYY-YYYY must be a Twilio validated phone number
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/SMS/Messages", "POST", array("To" => $in['recipient'], "From" => $in['twilio_from'], "Body" => $in['message']));
if ($response->IsError) {
    echo "Error: {$response->ErrorMessage}";
} else {
    echo "1";
}
//     }
예제 #12
0
 function make_call_path($to, $callerid, $path, $rest_access)
 {
     $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token);
     $recording_url = site_url("twiml/redirect/{$path}/{$rest_access}");
     $response = $twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array("Caller" => PhoneNumber::normalizePhoneNumberToE164($callerid), "Called" => PhoneNumber::normalizePhoneNumberToE164($to), "Url" => $recording_url));
     if ($response->IsError) {
         error_log($from);
         error_log(var_export($response, true));
         throw new VBX_CallException($response->ErrorMessage);
     }
 }
예제 #13
0
/**
 * Takes the list of contacts and
 * sends a text to each contact
 */
function sms_notification($contacts)
{
    // include the PHP TwilioRest library
    require "twilio.php";
    // twilio REST API version
    $ApiVersion = "2010-04-01";
    // Set Account Info
    $AccountSid = "ACf63d3cb5902475595edc2779af263041";
    $AuthToken = "952d9c152078c41ca5ccfd78845e02bf";
    // instantiate a new Twilio Rest Client
    $client = new TwilioRestClient($AccountSid, $AuthToken);
    // Send Each Contact a Text Message
    foreach ($contacts as $contact) {
        // Send a new outgoinging SMS by POSTing to the SMS resource */
        $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/SMS/Messages", "POST", array("To" => $contact['num'], "From" => "323-419-0097", "Body" => $contact['body']));
        if ($response->IsError) {
            return "Error: {$response->ErrorMessage}";
        } else {
            return "Sent message: " . $contact['body'] . "";
        }
    }
}
예제 #14
0
파일: send_sms.php 프로젝트: romley/xebura
<?php

// Include the PHP TwilioRest library
require "twilio.php";
// Twilio REST API version
$ApiVersion = "2010-04-01";
// Set our AccountSid and AuthToken
$AccountSid = "ACbe5ef8d477fb3ba31549f3012e9ba769";
$AuthToken = "e877310d768bcbde705235d4b0298caa";
// Outgoing Caller ID you have previously validated with Twilio
//$CallerID = '424-245-9689';
$CallerID = '415-599-2671';
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// ========================================================================
// 1. Initiate a new outbound call to 415-555-1212
//    uses a HTTP POST
$data = array("From" => $CallerID, "To" => "424-245-9689", "Body" => "This is a test message from Xebura! Reply STOP to unsubscribe");
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/SMS/Messages", "POST", $data);
print_r($response);
// check response for success or error
if ($response->IsError) {
    echo "Error sending text: {$response->ErrorMessage}\n";
} else {
    echo "Sent text: {$response->ResponseXml->Call->Sid}\n";
}
예제 #15
0
<?php
require "twiliorest.php";

$ApiVersion = "2008-08-01";

$user_id= $_GET['userid'];
$AccountSid = "YOURACCNTID";
$AuthToken = "YOURTOKEN";


$client = new TwilioRestClient($AccountSid, $AuthToken);


mysql_connect("myserverlocalhost","dbuser","dbdpwd");
 mysql_select_db("twliodb");



$result=mysql_query("select * from clients where id = '$user_id'") or die(mysql_error());
while($row = mysql_fetch_array($result)){


$mobile = $row["mobile"];
$first_name= $row["first_name"];
$last_name= $row["last_name"];
$name= $first_name."".$last_name;


        $response = $client->request("/$ApiVersion/Accounts/ $AccountSid /SMS/Messages",
            "POST", array(
            "To" => $mobile,
예제 #16
0
<?php

require_once 'include.php';
header('Content-type: text/xml');
$agent = $_REQUEST['agent'];
$lead = $_REQUEST['lead'];
$client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Agent likes the lead
if ($_REQUEST['Digits'] == '1') {
    // Agent likes the lead, so put them back in a conference together
    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $agent, 'POST', array('Url' => BASE_URL . 'conference.xml'));
    if ($response->IsError) {
        echo '<Response><Say>' . $response->ErrorMessage . '</Say></Response>';
    }
} else {
    echo '<Response><Say voice="woman">Sorry about that. Disconnecting you.</Say><Hangup /></Response>';
    // Hang the lead up
    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $lead, 'POST', array('Url' => BASE_URL . 'reject.xml'));
}
예제 #17
0
 function validate_step3()
 {
     $json = array('success' => true, 'step' => 2, 'message' => 'success');
     $twilio_sid = $this->openvbx_settings['twilio_sid'];
     $twilio_token = $this->openvbx_settings['twilio_token'];
     require_once APPPATH . 'libraries/twilio.php';
     try {
         $twilio = new TwilioRestClient($twilio_sid, $twilio_token);
         $response = $twilio->request("Accounts/{$twilio_sid}", 'GET', array());
         if ($response->IsError) {
             if ($response->HttpStatus > 400) {
                 $json['errors'] = array('twilio_sid' => $response->ErrorMessage, 'twilio_token' => $response->ErrorMessage);
                 throw new InstallException('Invalid Twilio SID or Token');
             }
             throw new InstallException($response->ErrorMessage);
         }
     } catch (InstallException $e) {
         $json['success'] = false;
         $json['message'] = $e->getMessage();
         $json['step'] = $e->getCode();
     }
     return $json;
 }
예제 #18
0
 function cancel_recording()
 {
     $json = array('error' => false, 'message' => '');
     $audio_file_id = $this->input->post('id');
     if (strlen($audio_file_id) == 0) {
         $json['error'] = true;
         $json['message'] = "Missing 'id' parameter.";
     } else {
         $audioFile = VBX_Audio_File::get($audio_file_id);
         if (is_null($audioFile)) {
             trigger_error("We were given an id for an audio_file, but we can't find the record.\t That's odd.  And, by odd I really mean it should *never* happen.");
         } else {
             if ($audioFile->user_id != $this->session->userdata('user_id')) {
                 trigger_error("You can't cancel a recording you didn't start.");
             } else {
                 $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
                 error_log("Redirecting to cancel page!");
                 $response = $twilio->request("Accounts/{$this->twilio_sid}/Calls/" . $audioFile->recording_call_sid, 'POST', array("CurrentUrl" => site_url('audiofiles/hangup_on_cancel')));
                 $audioFile->cancelled = true;
                 $audioFile->save();
             }
         }
     }
     $data = array();
     $data['json'] = $json;
     $this->response_type = 'json';
     $this->respond('', null, $data);
 }
<?php

phpinfo();
// Include the PHP TwilioRest library
require "twilio.php";
// Twilio REST API version
$ApiVersion = "2010-04-01";
// Set our AccountSid and AuthToken
$AccountSid = "ACab28583e662dcbf859ad7c0bf28d79b3";
$AuthToken = "454323a547b60b63f55faa44849959cc";
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// make an associative array of server admins
$people = array("7863038438" => "Gabriel");
// Iterate over all our server admins
foreach ($people as $number => $name) {
    // Send a new outgoinging SMS by POST'ing to the SMS resource */
    // YYY-YYY-YYYY must be a Twilio validated phone number
    $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/SMS/Messages", "POST", array("To" => $number, "From" => "415-599-2671", "Body" => "This is just a test from direksys sms notifications"));
    if ($response->IsError) {
        echo "Error: {$response->ErrorMessage}";
    } else {
        echo "Sent message to {$name}";
    }
}
예제 #20
0
<?php

// Include the PHP TwilioRest library
require "twilio.php";
// Twilio REST API version
$ApiVersion = "2010-04-01";
// Set our AccountSid and AuthToken
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Outgoing Caller ID you have previously validated with Twilio
$CallerID = 'NNNNNNNNNN';
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// ========================================================================
// 1. Initiate a new outbound call to 415-555-1212
//    uses a HTTP POST
$data = array("From" => $CallerID, "To" => "415-555-1212", "Url" => "http://demo.twilio.com/welcome");
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/Calls", "POST", $data);
// check response for success or error
if ($response->IsError) {
    echo "Error starting phone call: {$response->ErrorMessage}\n";
} else {
    echo "Started call: {$response->ResponseXml->Call->Sid}\n";
}
// ========================================================================
// 2. Get a list of recent calls
// uses a HTTP GET
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/Calls", "GET");
if ($response->IsError) {
    echo "Error fetching recent calls: {$response->ErrorMessage}";
} else {
예제 #21
0
파일: sms.php 프로젝트: jeffrono/cnvrgeapp
<?php

// need to fix this
// when user sends text, identify the TO number as the id for the event (all events will have unique phone numbers)
$sms = $_POST['Body'];
$sms = rtrim($sms);
$from = $_POST['From'];
$to = $_POST['To'];
require_once 'dbFunctions.php';
require "twilio.php";
$ApiVersion = "2010-04-01";
$client = new TwilioRestClient($AccountSid, $AuthToken);
$link = db_connect();
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>";
// get the event info
$query = "select * from event where twilio_phone = '{$to}';";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
$event_name = $row['name'];
$event_id = $row['id'];
$outgoing_twilio = $row['phone_number'];
$question = $row['question'];
//"Now give a 3 word bio.";
// get event info
$query = "select * from user where twilio = '{$from}' and event_id = {$event_id} limit 1;";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
$u_status = 0;
$u_status = $row['status'];
$u_name = $row['fname'];
}
$minimum_external = array(5 => 30, 10 => 50, 15 => 60, 20 => 70);
// 	echo set_coupon_external('3','','',5,$minimum_external[5],'www.innovashop.tv/gift_sms')."<br>";
// // 	echo (4 % 4)."<br>";
// // 	echo (3 % 4)."<br>";
// // 	echo (2 % 4)."<br>";
// // 	echo (1 % 4)."<br>";
// // 	echo (0 % 4)."<br>";
// 	return;
// Include the PHP TwilioRest library
require "twilio.php";
// Twilio REST API version
$ApiVersion = "2010-04-01";
// Set our AccountSid and AuthToken
$AccountSid = "ACab28583e662dcbf859ad7c0bf28d79b3";
$AuthToken = "454323a547b60b63f55faa44849959cc";
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// make an associative array of server admins
$people = array("7024150544" => "7024150544", "4848095924" => "4848095924", "4106249335" => "4106249335", "8155055787" => "8155055787", "2148547074" => "2148547074", "2148817818" => "2148817818", "2147158065" => "2147158065", "2146078480" => "2146078480", "9803288215" => "9803288215", "9563424185" => "9563424185", "9045543263" => "9045543263", "3054672615" => "3054672615", "9563424185" => "9563424185", "9512964397" => "9512964397", "8058901699" => "8058901699", "9802009997" => "9802009997", "3134240913" => "3134240913", "4693353497" => "4693353497", "9723588145" => "9723588145", "7608990114" => "7608990114", "3134240913" => "3134240913", "2139092084" => "2139092084", "6269230249" => "6269230249", "9727488756" => "9727488756", "8173171009" => "8173171009", "8052481918" => "8052481918", "4694466857" => "4694466857", "7143910850" => "7143910850", "7135843055" => "7135843055", "7862004423" => "7862004423", "9092324439" => "9092324439", "6822215143" => "6822215143", "2148593338" => "2148593338", "4093384907" => "4093384907", "2106072643" => "2106072643", "3234455131" => "3234455131");
// Iterate over all our server admins
foreach ($people as $number => $name) {
    // Send a new outgoinging SMS by POST'ing to the SMS resource */
    // YYY-YYY-YYYY must be a Twilio validated phone number
    $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/SMS/Messages", "POST", array("To" => $number, "From" => "760-547-7777", "Body" => "Felicitaciones! Su regalo lo puede pedir en www.innovashop.tv/sms o llamandonos al 888-448-7762 y usando esta clave " . set_coupon_external('3', '', '', 5, $minimum_external[5], 'www.innovashop.tv/gift_sms')));
    if ($response->IsError) {
        echo "Error: {$response->ErrorMessage}";
    } else {
        echo "Sent message to {$name}";
    }
}
예제 #23
0
<?php

require_once 'include.php';
$client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get the call SIDs of each caller
$response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls', 'GET', array('Status' => 'in-progress'));
if ($response->IsError) {
    echo 'Error: ' . $response->ErrorMessage;
} else {
    foreach ($response->ResponseXml->Calls->Call as $call) {
        if ($call->To == AGENT) {
            $agent = $call->Sid;
        } else {
            if ($call->To == FROM_NUMBER) {
                $lead = $call->Sid;
            }
        }
    }
}
if (strlen($agent) == 34 && strlen($lead) == 34) {
    echo 'Injecting &lt;Gather&gt;<br>';
    // Place the lead on hold
    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $lead, 'POST', array('Url' => BASE_URL . 'hold.xml'));
    // The lead has been put in the conference room, get their new call SID.
    $lead = $response->ResponseXml->Call->Sid;
    // Inject a gather for the agent
    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $agent, 'POST', array('Url' => BASE_URL . 'gather.php?agent=' . $agent . '&lead=' . $lead));
} else {
    echo 'Could not get call SIDs for the calls. Please ensure that the call is active and that both agent and lead can hear each other. If so, please refresh the page to try again.';
}
예제 #24
0
파일: _json.php 프로젝트: jsoncorwin/ACD
<?php

$base_uri = "Accounts/" . $this->twilio_sid;
$client = new TwilioRestClient($this->twilio_sid, $this->twilio_token);
$conferences = $client->request($base_uri . "/Conferences?Status=1", "GET");
$queues = array();
foreach ($conferences->ResponseXml->Conferences->Conference as $conference) {
    if (substr($conference->FriendlyName, 0, strlen("QUEUE_")) == "QUEUE_") {
        if (preg_match('/^QUEUE_([A-Za-z0-9_]+)_.+$/', $conference->FriendlyName, $matches)) {
            $queue_name = "{$matches[1]}";
            if (!array_key_exists($queue_name, $queues)) {
                $queues[$queue_name] = array();
            }
            $participants = $client->request($base_uri . "/Conferences/{$conference->Sid}/Participants", "GET");
            if (count($participants->ResponseXml->Participants->Participant) == 1) {
                foreach ($participants->ResponseXml->Participants->Participant as $participant) {
                    $call = $client->request($base_uri . "/Calls/{$participant->CallSid}", "GET");
                    $queues[$queue_name][$participant->CallSid . ""] = array("call" => $call->ResponseXml->Call, "participant" => $participant);
                }
            }
        }
    }
}
$out_queue = array();
foreach ($queues as $i => $queue) {
    $out_queue[$i] = array();
    foreach ($queue as $c => $call) {
        $entry = array();
        $entry['queueName'] = $i;
        $entry['callSid'] = $c;
        $entry['caller'] = (string) $call['call']->Caller;
예제 #25
0
파일: twiml.php 프로젝트: jsoncorwin/ACD
<?php

$ci =& get_instance();
$confname = "";
//Get list of running conferences that have not started
$client = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token);
$conferences = $client->request("Accounts/" . $ci->twilio_sid . "/Conferences?Status=1", "GET");
$queue_conferences = array();
foreach ($conferences->ResponseXml->Conferences->Conference as $conference) {
    if (substr($conference->FriendlyName, 0, strlen("QUEUE_" . AppletInstance::getValue("queue_name"))) == "QUEUE_" . AppletInstance::getValue("queue_name")) {
        $queue_conferences[] = $conference;
    }
}
foreach ($queue_conferences as $queue_conf) {
    $participants = $client->request("Accounts/" . $ci->twilio_sid . "/Conferences/{$queue_conf->Sid}/Participants");
    if (count($participants->ResponseXml->Participants->Participant)) {
        $confname = $queue_conf->FriendlyName;
        break;
    }
}
//get the next conference
if ($confname != "") {
    ?>

<Response>
  <Dial action="" hangupOnStar="true">
    <Conference beep="false" participantLimit="2" endConferenceOnExit="true" startConferenceOnEnter="true">
      <?php 
    echo $confname;
    ?>
    </Conference>
예제 #26
0
<?php

require_once 'include.php';
$client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Someone hung up, so hang the other person up as well.
if ($_REQUEST['CallStatus'] == 'completed') {
    // Find out who's still on the call
    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls', 'GET', array('Status' => 'in-progress'));
    if (!$response->IsError) {
        foreach ($response->ResponseXml->Calls->Call as $call) {
            if ($call->To == AGENT) {
                $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $call->Sid, 'POST', array('Url' => BASE_URL . 'lead-hungup.xml'));
            } else {
                if ($call->To == FROM_NUMBER) {
                    $response = $client->request('/' . API_VERSION . '/Accounts/' . ACCOUNT_SID . '/Calls/' . $call->Sid, 'POST', array('Url' => BASE_URL . 'agent-hungup.xml'));
                }
            }
        }
    }
}
<?php

require_once './include/config.php';
$client = new TwilioRestClient($AccountSid, $AuthToken);
if (isset($_REQUEST['Sid'])) {
    //update a Twilio number
    $data = array("FriendlyName" => $_REQUEST['friendly_name'], "VoiceUrl" => $_REQUEST['url']);
    $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/IncomingPhoneNumbers/" . $_REQUEST['Sid'], "POST", $data);
    if ($response->IsError) {
        echo "Erro ao atualizaro o numero: {$response->ErrorMessage}\n";
    } else {
        echo "<div class=\"confirm\"><img src=\"images/check.png\">Updated: {$response->ResponseXml->IncomingPhoneNumber->PhoneNumber}</div>";
    }
}
if (isset($_REQUEST['area_code'])) {
    //purchase new Twilio number
    $data = array("FriendlyName" => $_REQUEST['friendly_name'], "VoiceUrl" => $_REQUEST['url'], "AreaCode" => $_REQUEST['area_code']);
    $response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/IncomingPhoneNumbers", "POST", $data);
    if ($response->IsError) {
        echo "Error purchasing phone number: {$response->ErrorMessage}\n";
    } else {
        echo "<div class=\"confirm\"><img src=\"images/check.png\">Purchased: {$response->ResponseXml->IncomingPhoneNumber->PhoneNumber}</div>";
    }
}
$twilio_numbers = Util::get_all_twilio_numbers();
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/IncomingPhoneNumbers", "GET");
// Obtem os numeros de telefone
?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

	<html lang="en">
예제 #28
0
파일: site.php 프로젝트: JeffaCubed/OpenVBX
 private function add_tenant()
 {
     $tenant = $this->input->post('tenant');
     if (!empty($tenant)) {
         try {
             $data['id'] = $this->settings->tenant($tenant['url_prefix'], urlencode($tenant['url_prefix']), '');
             $this->db->trans_start();
             $user = new VBX_User();
             $user->fields[] = 'tenant_id';
             // monkey patching to override tenant_id
             $user->first_name = '';
             $user->last_name = '';
             $user->password = '';
             $user->values['tenant_id'] = $data['id'];
             // hidden field not in ORM
             $user->email = $tenant['admin_email'];
             $user->is_active = TRUE;
             $user->is_admin = TRUE;
             $user->auth_type = 1;
             try {
                 $user->save();
                 $user->send_new_user_notification();
             } catch (VBX_UserException $e) {
                 throw new VBX_SettingsException($e->getMessage());
             }
             foreach ($this->settings->setting_options as $param) {
                 $this->settings->add($param, '', $data['id']);
             }
             $this->settings->set('from_email', $tenant['admin_email'], $data['id']);
             try {
                 $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
                 $friendlyName = $tenant['url_prefix'] . ' - ' . $tenant['admin_email'];
                 $friendlyName = substr($friendlyName, 0, 32);
                 $response = $twilio->request("Accounts", 'POST', array('FriendlyName' => $friendlyName));
                 if ($response && $response->IsError != true) {
                     $account = $response->ResponseXml;
                     $tenant_sid = (string) $account->Account->Sid;
                     $tenant_token = (string) $account->Account->AuthToken;
                     $this->settings->add('twilio_sid', $tenant_sid, $data['id']);
                     $this->settings->add('twilio_token', $tenant_token, $data['id']);
                 } else {
                     $message = 'Failed to create new subaccount';
                     if ($response && $response->ErrorMessage) {
                         $message = $response->ErrorMessage;
                     }
                     throw new VBX_SettingsException($message);
                 }
                 $appSid = $this->create_application_for_subaccount($data['id'], $tenant['url_prefix'], $tenant_sid);
                 $this->settings->add('application_sid', $appSid, $data['id']);
             } catch (Exception $e) {
                 throw new VBX_SettingsException($e->getMessage());
             }
             $this->db->trans_complete();
             $this->session->set_flashdata('error', 'Added new tenant');
             if (isset($data['id'])) {
                 return redirect('settings/site/tenant/' . $data['id']);
             }
         } catch (VBX_SettingsException $e) {
             error_log($e->getMessage());
             $this->db->trans_rollback();
             // TODO: rollback in twilio.
             $this->session->set_flashdata('error', $e->getMessage());
             $data['error'] = true;
             $data['message'] = $e->getMessage();
         }
     }
     if ($this->response_type == 'html') {
         redirect('settings/site');
     }
     $this->respond('', 'settings/site', $data);
 }
예제 #29
0
<?php

$web = 0;
//------------------------------------------------------
//
// Include Files
//
//------------------------------------------------------
require "random_code.php";
require "twilio.php";
$ApiVersion = "2010-04-01";
$AccountSid = "<<TWILIO ACCOUNT SID>>";
$AuthToken = "<<TWILIO ACCOUNT TOKEN>>";
$client = new TwilioRestClient($AccountSid, $AuthToken);
//------------------------------------------------------
//
// Set Variables
//
//------------------------------------------------------
$db_host = 'localhost';
$db_name = '<<DB NAME>>';
$db_user = '******';
$db_passwd = '<<DB PASSWORD>>';
if ($web) {
    $pressbuzzer = 'BUZZER PRESS';
    $pressgarage = 'GARAGE PRESS';
    $body = htmlspecialchars($_GET["Body"]);
    $sender = "+" . htmlspecialchars($_GET["Sender"]);
    // TWilio sends number as +1XXXXXXXXXX
    $twinum = '<<TWILIO NUMBER>>';
    // testing