disturbed99 Posted September 30, 2014 Share Posted September 30, 2014 I set up a Twilio number so a client could have a SMS keyword response setup... but I don't know how to get the contents of a file to be returned as the response. I am using the php functions..I setup a system so that my client could change the responses to different keywords. Basicly it uses a webform to change the contents of a file which gets returned as a response.What I need to know is how to read in the contents of the file into this function:BTW... this works fine and will return "READ_FILE_CONTENTS_INTO_HERE"function app(){$response = new Services_Twilio_Twiml();$response->sms("READ_FILE_CONTENTS_INTO_HERE");echo $response;}I tried this but it stopped the script dead:function app(){$response = new Services_Twilio_Twiml();$response->sms("<?php include 'file.txt'; ?>");echo $response;}Any ideas?ThanksBTW... below is the entire php script:<?php/* Include twilio-php, the official Twilio PHP Helper Library,* which can be found at* http://www.twilio.com/docs/libraries*/include('Services/Twilio.php');/* Controller: Match the keyword with the customized SMS reply. */function index(){$response = new Services_Twilio_Twiml();$response->sms("Thank You For Contacting SweetLeafAZ.com - Reply with one of the following keywords:APP = Make Appt, CS = Current Strains, DP = Delivery Prices, SP = Current Specials.");echo $response;}function app(){$response = new Services_Twilio_Twiml();$response->sms("http://www.vcita.com/v/24067915901f2c7d/home");echo $response;}function cs(){$response = new Services_Twilio_Twiml();$response->sms("http://mobile.dudamobile.com/site/sweetleafaz2");echo $response;}function dp(){$response = new Services_Twilio_Twiml();$response->sms("As of Sept 26 2014, Our Delivery Rates are $2 per mile during the hours of 9am to 6pm. No deliveries will be made after 6pm.");echo $response;}function sp(){$response = new Services_Twilio_Twiml();$response->sms("We are currently offering FREE delivery within 10 miles for orders over $100.");echo $response;}/* Read the contents of the 'Body' field of the Request. */$body = $_REQUEST['Body'];/* Remove formatting from $body until it is just lowercasecharacters without punctuation or spaces. */$result = preg_replace("/[^A-Za-z0-9]/u", " ", $body);$result = trim($result);$result = strtolower($result);/* Router: Match the ‘Body’ field with index of keywords */switch ($result) {case 'app’':app();break;case 'cs':cs();break;case 'dp':dp();break;case 'sp':sp();break;/* Optional: Add new routing logic above this line. */default:index();} Link to comment https://forums.phpfreaks.com/topic/291361-how-do-i-insert-file-contents-into-response/ Share on other sites More sharing options...
Ch0cu3r Posted September 30, 2014 Share Posted September 30, 2014 I tried this but it stopped the script dead: Why have are you using PHP tags within a string? One way to read the contents of a file is to use file_get_contents, example $response->sms( file_get_conents('file.txt') ); Link to comment https://forums.phpfreaks.com/topic/291361-how-do-i-insert-file-contents-into-response/#findComment-1492452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.