修正bug
This commit is contained in:
parent
c9cfc49650
commit
5c565a1a50
@ -16,14 +16,14 @@ class Oauth2Controller extends ControllerBase{
|
||||
* http://127.0.0.1/tiffany/api/oauth2/test?qaz=wsx
|
||||
*/
|
||||
function testAction(){
|
||||
$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/accesstoken";
|
||||
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/accesstoken";
|
||||
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code";
|
||||
//$url = "http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx";
|
||||
//$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'] = "f74311c97fc7440895b6019a0d5234ae";
|
||||
$post_arr['code'] = "0db13957334c4244b03267b9ce9ccd7b";
|
||||
$post_json = json_encode($post_arr);
|
||||
$result = $this->__http_post_request($url, $post_json, true);
|
||||
print_r($result); die;
|
||||
@ -112,7 +112,7 @@ class Oauth2Controller extends ControllerBase{
|
||||
if(empty($rs['errcode'])){
|
||||
//准备更新当天请求次数
|
||||
$AppInfo->LastModifiedTime = $current_datetime;
|
||||
//更新字段
|
||||
//其他字段
|
||||
$AppInfo->TodayReqTimes = $today_req_times;
|
||||
$AppInfo->LastReqTime = $current_date;
|
||||
//如果更新失败
|
||||
@ -139,7 +139,7 @@ class Oauth2Controller extends ControllerBase{
|
||||
//准备更新临时code
|
||||
$TempCode->LastModifiedTime = $current_datetime;
|
||||
}
|
||||
//更新字段
|
||||
//其他字段
|
||||
$TempCode->Code = $code = $this->_get_act_code(32);
|
||||
$TempCode->IsUsed = 0;
|
||||
$TempCode->ExpireTime = date("Y-m-d H:i:s", $current_time+300);
|
||||
@ -172,7 +172,7 @@ class Oauth2Controller extends ControllerBase{
|
||||
*/
|
||||
function accesstokenAction(){
|
||||
//如果未获取到请求数据
|
||||
if(empty($this->request->getPost())){
|
||||
if(empty(file_get_contents("php://input"))){
|
||||
//告知用户系统繁忙,请稍候再试
|
||||
$rs['errcode'] = -1;
|
||||
$rs['errmsg'] = "系统繁忙,请稍候再试";
|
||||
@ -267,7 +267,7 @@ class Oauth2Controller extends ControllerBase{
|
||||
if(empty($rs['errcode'])){
|
||||
//准备更新当天请求次数
|
||||
$AppInfo->LastModifiedTime = $current_datetime;
|
||||
//更新字段
|
||||
//其他字段
|
||||
$AppInfo->TodayReqTimes = $today_req_times;
|
||||
$AppInfo->LastReqTime = $current_date;
|
||||
//如果更新失败
|
||||
@ -326,24 +326,26 @@ class Oauth2Controller extends ControllerBase{
|
||||
//如果code未使用过
|
||||
else{
|
||||
//查询当前接口过去是否有生成过access_token
|
||||
$AccessToken = AccessToken::findFirst("AppId = $appid");
|
||||
$AccessToken = AccessToken::findFirst("AppId = '$appid'");
|
||||
//如果当前接口过去未生成过access_token
|
||||
if(empty($AccessToken)){
|
||||
//准备新增AccessToken
|
||||
$AccessToken = new AccessToken();
|
||||
$AccessToken->Id = $this->_get_act_code(32);
|
||||
$AccessToken->AppId = $appid;
|
||||
$AccessToken->PrevAccessToken = null;
|
||||
$AccessToken->CreateTime = $current_datetime;
|
||||
$AccessToken->LastModifiedTime = $current_datetime;
|
||||
}
|
||||
//如果当前接口过去有生成过access_token
|
||||
else{
|
||||
//准备更新AccessToken
|
||||
$AccessToken->PrevAccessToken = $AccessToken->AccessToken;
|
||||
$AccessToken->LastModifiedTime = $current_datetime;
|
||||
}
|
||||
//更新字段
|
||||
$AccessToken->Code = $code = $this->_get_act_code(32);
|
||||
$AccessToken->IsUsed = 0;
|
||||
$AccessToken->ExpireTime = date("Y-m-d H:i:s", $current_time+300);
|
||||
//其他字段
|
||||
$AccessToken->AccessToken = $access_token = $this->_get_act_code(32);
|
||||
$AccessToken->ExpireTime = date("Y-m-d H:i:s", $current_time+14400);
|
||||
//如果保存失败
|
||||
if(!($AccessToken->save())){
|
||||
//告知用户系统繁忙,请稍候再试
|
||||
@ -358,6 +360,7 @@ class Oauth2Controller extends ControllerBase{
|
||||
$rs['errcode'] = 0;
|
||||
$rs['data']['access_token'] = $access_token;
|
||||
$rs['data']['expire_in'] = 14400;
|
||||
$rs['data']['refresh_token'] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user