From 5e032d19fdeb3bbcb80d40a485f7f9baeb475b91 Mon Sep 17 00:00:00 2001 From: qinzongqing Date: Mon, 17 Apr 2023 16:46:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4code=E5=8F=8Aaccess=5Ftoken?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ControllerBase.php | 9 --------- app/controllers/Oauth2Controller.php | 12 ++++++------ app/controllers/SmsController.php | 9 +++++---- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app/controllers/ControllerBase.php b/app/controllers/ControllerBase.php index 3ec8398..9604cc2 100644 --- a/app/controllers/ControllerBase.php +++ b/app/controllers/ControllerBase.php @@ -145,15 +145,6 @@ class ControllerBase extends Phalcon\Mvc\Controller{ return $configData; } - /** - * 随机生成字符串 - */ - function _get_act_code($digit=32){ - $str = 'abcdefghijklmnopqrstuvwxyz0123456789'; - $code = substr(str_shuffle($str), 0, $digit); - return $code; - } - /** * 校验是否有收到请求数据 */ diff --git a/app/controllers/Oauth2Controller.php b/app/controllers/Oauth2Controller.php index 3fa8b2c..6cd0289 100644 --- a/app/controllers/Oauth2Controller.php +++ b/app/controllers/Oauth2Controller.php @@ -17,14 +17,14 @@ class Oauth2Controller extends ControllerBase{ * http://weapp.wemediacn.net/d/tiffany/api/oauth2/test?qaz=wsx */ function testAction(){ - $url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code"; + //$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code"; //$url = "http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx"; //$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/accesstoken"; - //$url = "http://127.0.0.1/tiffany/api/oauth2/accesstoken?qaz=wsx"; + $url = "http://127.0.0.1/tiffany/api/oauth2/accesstoken?qaz=wsx"; $post_arr = array(); $post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7"; $post_arr['appsecrect'] = "b82015bd-8d4c-4df8-87a8-c25477a8976f"; - $post_arr['code'] = "b4ed9dabbe1f4dd5bc824046d37922d5"; + $post_arr['code'] = "b877e2d843ef2c21fc28e7126423d217"; $post_json = json_encode($post_arr); $result = $this->__http_post_request($url, $post_json, true); print_r($result); die; @@ -70,7 +70,7 @@ class Oauth2Controller extends ControllerBase{ $TempCode->LastModifiedTime = $this->current_datetime; } //其他字段 - $TempCode->Code = $code = $this->_get_act_code(32); + $TempCode->Code = $code = md5(uniqid(mt_rand(), true)); $TempCode->IsUsed = 0; $TempCode->ExpireTime = date("Y-m-d H:i:s", $this->current_time+300); //如果保存失败 @@ -196,7 +196,7 @@ class Oauth2Controller extends ControllerBase{ if(empty($AccessToken)){ //准备新增AccessToken $AccessToken = new AccessToken(); - $AccessToken->Id = $this->_get_act_code(32); + $AccessToken->Id = md5(uniqid(mt_rand(), true)); $AccessToken->AppId = $appid; $AccessToken->PrevAccessToken = null; $AccessToken->CreateTime = $this->current_datetime; @@ -216,7 +216,7 @@ class Oauth2Controller extends ControllerBase{ } } //其他字段 - $AccessToken->AccessToken = $access_token = $this->_get_act_code(32); + $AccessToken->AccessToken = $access_token = md5(uniqid(mt_rand(), true)); $AccessToken->ExpireTime = date("Y-m-d H:i:s", $this->current_time+14400); //如果保存失败 if(!($AccessToken->save())){ diff --git a/app/controllers/SmsController.php b/app/controllers/SmsController.php index f247cbd..a1a7b67 100644 --- a/app/controllers/SmsController.php +++ b/app/controllers/SmsController.php @@ -45,7 +45,7 @@ class SmsController extends ControllerBase{ $post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7"; $post_arr['mobile'] = "13501882318"; $post_arr['access_token'] = "9d21508a7531430c843cff8063dccb1c"; - $post_arr['access_token'] = "ycq9t62einm7usfah1vk4z38djxp5gwl"; + $post_arr['access_token'] = "520aec4ea5b42e1bc6d4549eeac26c14"; $post_arr['content'] = "[$=yzm=$]、[$=params1=$]、[$=params2=$]、[$=params3=$]、[$=params4=$]、[$=params5=$]"; $post_arr['format'] = ""; $post_arr['len'] = -1; @@ -57,10 +57,11 @@ class SmsController extends ControllerBase{ $post_arr['params5'] = 5; $post_arr['params6'] = 6; $post_arr['is_resend'] = true; - $post_arr['min_id'] = 4115398953; - $post_arr['min_id'] = 4116344287; - $post_arr['min_id'] = 4116344229; $post_arr['min_id'] = 0; + $post_arr['min_id'] = 4121165901; + $post_arr['min_id'] = 4120793819; + $post_arr['min_id'] = 4121165413; + $post_arr['min_id'] = 4121165408; $post_json = json_encode($post_arr); $result = $this->__http_post_request($url, $post_json, true); print_r($result); die;