Created
July 22, 2011 20:55
-
-
Save rahims/1100405 to your computer and use it in GitHub Desktop.
Sample code on how to take an SMS and respond with an SMS based on what the person sent in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/xml'); | |
echo '<?xml version="1.0" encoding="UTF-8"?>'; | |
?> | |
<Response> | |
<?php | |
// When an SMS comes into your Twilio phone number, Twilio passes | |
// the body of the SMS to your web app in the Body parameter. | |
$keyword = strtolower(trim($_REQUEST['Body'])); | |
switch ($keyword) | |
{ | |
case 'hi': | |
$reply = 'Hello there!'; | |
break; | |
case 'are you a human?': | |
$reply = 'Of course I am!'; | |
break; | |
case 'oh yeah? prove it!': | |
$reply = 'Uh...how would I do that?'; | |
break; | |
// And so on | |
default: | |
$reply = 'Sorry what was that?'; | |
} | |
echo "<Sms>$reply</Sms>"; | |
?> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment