/** * 分析token * @param $token * @return array|int|null */ public function _analysisToken($token) { //解密 $arr = explode('_', Util::aesDecode($token)); //验证码错误 if (count($arr) < 3 || $arr[2] !== C('TOKEN_DISTURB_CODE')) { return null; } //验证码过期,一周失效 if ($arr[1] < $this->time - C('TOKEN_EXPIRES_IN')) { return -1; } //24小时续期 // println('当前服务器时间:'.$this->time,false); // println('时间差:'$this->time-$arr[1],false); // print_r(C('TOKEN_REFRESH_TIME'));die; if ($this->time - $arr[1] > C('TOKEN_REFRESH_TIME')) { return array('userId' => $arr[0], 'mktime' => $arr[1], 'refresh_token' => $this->_createToken($arr[0])); } return array('userId' => $arr[0], 'mktime' => $arr[1]); }