Skip to content

Instantly share code, notes, and snippets.

@kadashu
Created October 31, 2012 07:26
Show Gist options
  • Save kadashu/3985602 to your computer and use it in GitHub Desktop.
Save kadashu/3985602 to your computer and use it in GitHub Desktop.
sms web interface
<?php
date_default_timezone_set('Asia/Shanghai');
# get args
$user = $_GET["user"];
$pass = $_GET["pass"];
$msg = $_GET["msg"];
$msg_dc = urldecode( $msg );
$tolist = array();
$tolist = split(',',$_GET["to"]);
# push into redis
function Push( $to, $msg ){
$redis = new Redis();
try {
$redis->connect('127.0.0.1', 6379);
# encode $to and $msg into a string
$redis->lPush('sms', "15011307334,412320118p,$to,$msg");
}
catch( Exception $e ) {
#echo "Date:".date('Y/m/d H:i:s', time()).";ERROR:".$e."\n";
echo "Date:".date('Y/m/d H:i:s', time()).";ERROR\n";
}
$redis->close();
}
# return status
for( $i=0; $i< count($tolist); $i++ ){
echo "User:".$user.";Pass:".$pass.";To:".$tolist[$i].";Msg=".$msg_dc."\n";
Push( $tolist[$i], $msg_dc );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment