Permalink
Browse files

Removed most of the stateful stuff and I'm trying to get just the bas…

…ics to work. Code is basically mid-debug at the moment.
  • Loading branch information...
1 parent 1241bd3 commit b9ab0ac27f7e4f9fe8ca3cd8ea4c9bf117212158 @kamron kamron committed Jul 29, 2012
Showing with 15 additions and 26 deletions.
  1. +15 −26 smsrequest.php
View
@@ -1,31 +1,21 @@
<?php
require ('./query.php');
-// start the session
-session_start();
-
-// This is the state we're in
-$state = $_SESSION['state'];
-// Previous query (if there is one)
-$state = $_SESSION['query'];
-
-// Create the state if you're ready!
-if(!strlen($state)) {
- $state = 'QUERY';
-}
-
-$sender = $_POST["From"] // The phone number that sent this message.
-$query = $_POST["Body"] // The text body of the SMS message. Up to 160 characters long.
-$pieces = explode(",", $_POST["Body"], 2); // Split the query into two
-
+// Allows me do debug!
+error_reporting(E_ALL);
+ini_set("display_errors",1);
+
+//setcookie("TestCookie", 'lolhi', time()+250); // Expires after 3-ish minutes
+$message='Something went wrong.'; // The final message to be sent
+$query = $_POST["Body"]; // The text body of the SMS message. Up to 160 characters long.
+$pieces = explode(',', $query, 2); // Split the query into two
+// echo "lol uh oh";
$results = get_results($pieces[0], $pieces[1]); // Pass in the data
-$message=''; // The final message to be sent
-
-if(count($results)>1) // Handles if there is more than result
+if(count($results)>-1) // Handles if there is more than one result (disabled for now)
{
if($state = 'MORE' && strcasecmp( 'MORE' , $query )==0) // Set back to QUERY after a MORE
{
- $message=$results[0]." ".$results[1];
+ $message=$results[0].' '.$results[1];
$state = 'QUERY';
$_SESSION['query']='';
}
@@ -36,7 +26,8 @@
$state = 'MORE';
}
}
-if(count($results==1))
+
+if(count($results>=1))
{
$message=$results[0]." ".$results[1];
}
@@ -46,11 +37,9 @@
$message='No results found!';
}
-$_SESSION['state'] = $state;
-
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
- <sms><?php echo $message; if(count($results)>1 && $state=='QUERY' ) ' Text MORE for more results.'; ?></sms>
-</Response>
+ <sms><?php echo $message;?><<?php if(count($results)>1) echo ' Text MORE for more results.'; ?>/sms>
+</Response>

0 comments on commit b9ab0ac

Please sign in to comment.