php - How do I take an SMS and make a call to alert someone based on what SMS says? -
so trying take incoming sms , based on sms says make call specific recording.
for example:
i have door sensor modem can send text twilio # when door open or when door closed.
if twilio receives "door open" text twilio call cell phone , plays recording says "door open"
if twilio receives "door closed" text twilio call cell phone , plays recording says "door closed"
<?php require_once('/home/protranx/public_html/twilio-php- latest/services/twilio.php'); $sid = "sid"; $token = "token"; $client = new services_twilio($sid, $token); $alert = $_request['body']; $twilionumber = "+twilio #"; $to = "+my cell #"; $url1 = "http://protran.x10.mx/oak1_armed_door_open.php"; $url2 = "http://protran.x10.mx/oak1_disarmed_door_closed.php"; $string1 = "door open"; $string2 = "door closed"; if ($alert == $string1){ $call = $client->account->calls->create($twilionumber, $to, $url1);} elseif ($alert == $string2){ $call = $client->account->calls->create($twilionumber, $to, $url2);} echo $call->sid; header('content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?> <response> </response> i keep getting error: error: 12100 - document parse failure
any appreciated.
thank you
twilio evangelist here.
hard tell code, looks right.
one thing trips me spaces being rendered before start of xml or between xml declaration , root element, might check either of since can hard catch.
for example, i'm not sure need newline have @ end of xml declaration.
hope helps.
Comments
Post a Comment