function help($from) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://" . $_SERVER['HTTP_HOST'] . "/api/user/smsHelp/" . $from); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_HEADER, 1); $request = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($request, 0, $header_size); $curl_body = substr($request, $header_size); $result = json_decode($curl_body, true); curl_close($ch); $response = new Services_Twilio_Twiml(); if ($result['result'] == '0') { //no user record found $response->sms("Younique Products\r\n\r\nWe have no record of an account associated with your phone number.\r\n\r\nReply STOP to opt-out.\r\n\r\nReply HELP for help.\r\n\r\nMessage & data rates may apply."); error_log('--------------------------------------------- /n Twilio default help service did not catch help reply. Someone replied help and we found no user record with an sms phone number matching the incoming number. /n phone number: "' . $from . '"/n---------------------------------------------', 0); } elseif ($result['result'] == '1') { //found a user record //this user has requested sms but hasn't opted-in yet $response->sms("Younique Products\r\n\r\nWe've received notice that you wished to opt-in to receive recurring SMS texts but have yet to confirm. Reply YES to complete the opt-in process.\r\n\r\nReply STOP to opt-out.\r\n\r\nReply HELP for help.\r\n\r\nMessage & data rates may apply."); error_log('--------------------------------------------- /n Twilio default help service did not catch help reply. Someone replied help and we found a user who had requested sms but has not opted-in yet. /n phone number: "' . $from . '"/n---------------------------------------------', 0); } elseif ($result['result'] == '2') { //found a user record //this user is not opted-in for sms $response->sms("Younique Products\r\n\r\nYou are NOT subscribed to receive recurring SMS texts from us. If you wish to opt-in: login to your account at www.youniqueproducts.com, go to your profile, and complete the SMS Texting Preferences section.\r\n\r\nReply STOP to opt-out.\r\n\r\nReply HELP for help.\r\n\r\nMessage & data rates may apply."); error_log('--------------------------------------------- /n Twilio default help service did not catch help reply. Someone replied help and we found a user who has not opted-in for sms. /n phone number: "' . $from . '"/n---------------------------------------------', 0); } else { //$result == '3' //found a user record //this user is opted-in for sms $response->sms("Younique Products\r\n\r\nYou are subscribed to receive recurring SMS texts from us.\r\n\r\nReply STOP to opt-out.\r\n\r\nReply HELP for help.\r\n\r\nMessage & data rates may apply."); error_log('--------------------------------------------- /n Twilio default help service did not catch help reply. Someone replied help and we found a user who is opted-in for sms. /n phone number: "' . $from . '"/n---------------------------------------------', 0); } echo $response; }
public function testSmsAddAttribute() { $r = new Services_Twilio_Twiml(); $r->sms(array("foo" => "bar")); $expected = '<Response><Sms foo="bar"></Sms></Response>'; $this->assertXmlStringEqualsXmlString($expected, $r); }
function hello() { $response = new Services_Twilio_Twiml(); $response->sms("hello from cs6432015 from GABRIEL RIBEIRO."); echo $response; }