Below is some code that I use to send some data to twilio's api.
The last part: StatusCallback: a variable or two in the url (State, city and name) need to be encoded. I've tried a number of ways but not sure I'm doing it right. Twilio suggested:
"I think you should wrap the entire contents of the StatusCallback in the urlencode() function. As is, I believe the system is getting confused on what is a parameter of the overall request versus the parameters of your callback."
I can't figure out how to do it as suggested.
$response = $client->request("/$ApiVersion/Accounts/$AccountSid/SMS/Messages",
"To" => $FromCaller,
"From" => $textcalldisplay,
"Body" => $subscribemessage,
"StatusCallback" => "http://www.mydomain.ca/app/application/third_party/twilio/callin/text_complete.php?ContestId=$contestid&account_id=$account_id&CallerState=$CallerState&CallerCity=$CallerCity"