The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Twilio Outgoing Multiple Calls
Posted by: Will Tran | April 19, 2010 @ 4:10pm
PHP Code
[
Download
]
== connect_company.php // after customer click call me it goes here == <?php require 'twilio.php'; $ApiVersion = "2008-08-01"; $AccountSid = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"; // Database gets a list of phone numbers to call $phone_numbers = array('XXXXXXXXXX', 'XXXXXXXXXX', 'XXXXXXXXXX'); $customer_number =$_REQUEST['customer_number']; $client = new TwilioRestClient($AccountSid, $AuthToken); /* make Twilio REST request to initiate outgoing call */ $response = $client->request("/$ApiVersion/Accounts/$AccountSid/Calls", "POST", array( "Caller" => $phone_numbers[0], "Called" => $outgoing, "Url" => $url . "start_call.php?customer_number={$customer_number}&company_numbers=".implode(',', $phone_numbers).'¤t_order=0' )); ?> == start_call.php // initializes TwiML. This also tracks the current number we are calling. == <?php $phone_numbers = explode(',', $_REQUEST['phone_numbers']); // Adds spaces between numbers for voice $voice_phone = implode(' ', str_split($_REQUEST['customer_number'])); ?> <Response> <!-- Gather is used to screen voicemail here --> <Gather action="connect_customer.php?customer_number=<?php echo $_REQUEST['customer_number'] ?>"> <Say>Press 1 to accept a call from a customer with phone number <?php echo $voice_phone ?>.</Say> </Gather> <!-- Make sure no out of bounds in array error --> <?php if($_REQUEST['current_order'] + 1 < count($phone_numbers)): ?> <!-- Redirect if no answer // Remember to escape your & as & in XML --> <Redirect url="start_call.php?customer_number=<?php echo $_REQUEST['customer_number'] ?>&company_numbers=<?php echo $_REQUEST['company_numbers'] ?>&current_order=".($_REQUEST['current_order'] + 1) /> <!-- No more numbers available. Could redirect here to call company voicemail. --> <?php else: ?> <Say>Sorry, no one available to answer your call. We will get back to you shortly.</Say> <?php endif; ?> </Response>
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.31 / 8
55 Votes
http://codebin.yi.org/597
page generated in 0.00 seconds