2

The Twilio docs say I can pass an NSDictionary of both pre-defined and arbitrary parameters to connect that will be passed along to my app server-side, which leads me to believe I can do something like this:

NSDictionary *params = @{@"Residence":@"Home"};
_connection = [_phone connect:params delegate:nil];

Then on the responding server, I'm catching that parameter, recording all of them and then also having the app "say" the arbitrary one I've passed:

$response = new Services_Twilio_Twiml();
$response->say("You're Calling");
$fh = fopen(getcwd().'/request.txt', 'w');
foreach($_REQUEST as $key=>$value) {
  fwrite($fh, $key.' - '.$value."\n");
}
fclose($fh);
$response->say($_GET['Residence']);
print $response;

The app says "You're calling" after the call is placed, but not Home, nor is the Residence parameter showing up at all in the log I'm writing to. Rather, I get all the regular stuff:

AccountSid - ####
ApplicationSid - ####
Caller - client:Anonymous
CallStatus - ringing
Called - 
To - 
CallSid - ####
From - client:Anonymous
Direction - inbound
ApiVersion - 2010-04-01

Am I doing something wrong or can I not pass arbitrary data this way?

UPDATE:

My current solution is to pass an additional $_GET variable when getting my token and then saving the parameter to a database with the token to be retrieved when the call is actually placed. Not ideal, but it works. If anyone has a better solution, I'd love to hear it. Otherwise I'll make an answer out of this.

Ethan C
  • 1,408
  • 1
  • 14
  • 26

0 Answers0