Skip to content

Instantly share code, notes, and snippets.

@ryankinal
Created February 8, 2013 00:28
Show Gist options
  • Save ryankinal/4735530 to your computer and use it in GitHub Desktop.
Save ryankinal/4735530 to your computer and use it in GitHub Desktop.
WTF strlen
<?php
// config file
define('STOP_MESSAGE', ' (txt "STOP" to cancel)');
// form handling
$length = 157 - strlen(STOP_MESSAGE) - strlen($keyword->getAttribute('word'));
$reply = isset($_POST['reply']) ? $_POST['reply'] : false;
if (strlen($reply) <= $length)
{
$keyword->setAttribute('auto_reply', $reply);
if ($keyword->save()) // save shit to the database all ORM style
{
$success = true;
}
else
{
$error = 'There was a problem saving your auto reply. Please try again.';
}
}
else
{
$error = "Hold up. That's a little too long.";
}
// On API call
$text = $keyword->getAttribute('auto_reply');
$text = $keyword->getAttribute('word').': '.$text.' '.STOP_MESSAGE;
// echo as XML
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment