Jump to content

How Do I Insert File Contents into Response?


disturbed99

Recommended Posts

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?

Thanks

BTW... 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 lowercase
characters 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.