Permalink
Browse files

Update for API version 2010-04-01

  • Loading branch information...
1 parent 3fd3e3c commit 32b9d1073b406909c9d20e5394eab3dc9b99e402 @chadsmith committed Feb 17, 2011
Showing with 12 additions and 15 deletions.
  1. +3 −2 applets/call/twiml.php
  2. +7 −11 applets/text/twiml.php
  3. +2 −2 outbound.php
View
@@ -7,11 +7,12 @@
$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
if(($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $ci->tenant->id)))&&$flow[0]->values['data'])
- $ci->twilio->request("Accounts/{$ci->twilio_sid}/Calls", 'POST', array('Caller' => $number, 'Called' => $recipient, 'Url' => site_url('twiml/start/voice/'.$id)));
+ $ci->twilio->request("Accounts/{$ci->twilio_sid}/Calls", 'POST', array('From' => $number, 'To' => $recipient, 'Url' => site_url('twiml/start/voice/'.$id)));
+
$response = new Response();
$next = AppletInstance::getDropZoneUrl('next');
if(!empty($next))
$response->addRedirect($next);
-$response->Respond();
+$response->Respond();
View
@@ -5,18 +5,14 @@
$recipient = normalize_phone_to_E164(AppletInstance::getValue('recipient'));
$message = AppletInstance::getValue('sms');
-if(AppletInstance::getFlowType() == 'voice'){
- $caller = normalize_phone_to_E164($_REQUEST['Caller']);
- $called = normalize_phone_to_E164($_REQUEST['Called']);
- $message = str_replace(array('%caller%', '%number%'), array($caller, $called), $message);
-}
-else{
- $from = normalize_phone_to_E164($_REQUEST['From']);
- $to = normalize_phone_to_E164($_REQUEST['To']);
+$from = normalize_phone_to_E164($_REQUEST['From']);
+$to = normalize_phone_to_E164($_REQUEST['To']);
+
+if(AppletInstance::getFlowType() == 'voice')
+ $message = str_replace(array('%caller%', '%number%'), array($from, $to), $message);
+else
$message = str_replace(array('%sender%', '%number%', '%body%'), array($from, $to, $_REQUEST['Body']), $message);
-}
-require_once(APPPATH . 'libraries/twilio.php');
$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
$ci->twilio->request("Accounts/{$ci->twilio_sid}/SMS/Messages", 'POST', array('To' => $recipient, 'From' => $number, 'Body' => $message));
@@ -26,4 +22,4 @@
if(!empty($next))
$response->addRedirect($next);
-$response->Respond();
+$response->Respond();
View
@@ -6,7 +6,7 @@
require_once(APPPATH . 'libraries/twilio.php');
$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
if($id&&($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $tenant_id)))&&$flow[0]->values['data'])
- $ci->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array('Caller' => $number, 'Called' => normalize_phone_to_E164($_POST['recipient']), 'Url' => site_url('twiml/start/voice/'.$id)));
+ $ci->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array('From' => $number, 'To' => normalize_phone_to_E164($_POST['recipient']), 'Url' => site_url('twiml/start/voice/'.$id)));
}
$flows = OpenVBX::getFlows(array('tenant_id' => $tenant_id));
?>
@@ -57,4 +57,4 @@
</fieldset>
</form>
</div>
-</div>
+</div>

0 comments on commit 32b9d10

Please sign in to comment.