参数
$token = strtoupper($_POST["token"]); $sign = strtoupper($_POST["sign"]);
页面调用
$ret_json = verify_signandtoken($sign,$token); $ret_arr = json_decode($ret_json); if($ret_arr->ret != 888){ echo $ret_json; }
逻辑实现
config_mysql.ini.php 的公用方法注册 function verify_signandtoken($sign,$token){ if($sign != strtoupper(md5($token.$keys))){ $returnData=array('ret'=>1011,'msg'=>'sign错误'); return json_encode($returnData); } $sql = "SELECT * FROM `AA_ANDROID_USER` WHERE `C_TOKEN` = '".$token."';"; $result = mysql_query($sql); $num = mysql_num_rows($result); $row = mysql_fetch_array($result); if($num != 1){ $returnData=array('ret'=>1010,'msg'=>'token过期或不存在'); return json_encode($returnData); } $returnData=array('ret'=>888,'msg'=>'ok'); return json_encode($returnData); }