微信/QQ支付返回参数优化

This commit is contained in:
Devil 2021-04-11 23:36:41 +08:00
parent 82da920b54
commit 922b03237b
2 changed files with 5 additions and 5 deletions

View File

@ -107,7 +107,7 @@ class QQ
// 请求获取session_key // 请求获取session_key
$url = 'https://api.q.qq.com/sns/jscode2session?appid='.$this->_appid.'&secret='.$this->_appsecret.'&js_code='.$authcode.'&grant_type=authorization_code'; $url = 'https://api.q.qq.com/sns/jscode2session?appid='.$this->_appid.'&secret='.$this->_appsecret.'&js_code='.$authcode.'&grant_type=authorization_code';
$result = $this->HttpRequestGet($url); $result = $this->HttpRequestGet($url);
if(!empty($result['openid'])) if(!empty($result) && !empty($result['openid']))
{ {
// 从缓存获取用户信息 // 从缓存获取用户信息
$key = 'qq_user_login_'.$result['openid']; $key = 'qq_user_login_'.$result['openid'];
@ -143,7 +143,7 @@ class QQ
// 网络请求 // 网络请求
$url = 'https://api.q.qq.com/api/getToken?grant_type=client_credential&appid='.$this->_appid.'&secret='.$this->_appsecret; $url = 'https://api.q.qq.com/api/getToken?grant_type=client_credential&appid='.$this->_appid.'&secret='.$this->_appsecret;
$result = $this->HttpRequestGet($url); $result = $this->HttpRequestGet($url);
if(!empty($result['access_token'])) if(!empty($result) && !empty($result['access_token']))
{ {
// 缓存存储 // 缓存存储
$result['expires_in'] += time(); $result['expires_in'] += time();

View File

@ -111,7 +111,7 @@ class Wechat
// 请求获取session_key // 请求获取session_key
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$this->_appid.'&secret='.$this->_appsecret.'&js_code='.$params['authcode'].'&grant_type=authorization_code'; $url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$this->_appid.'&secret='.$this->_appsecret.'&js_code='.$params['authcode'].'&grant_type=authorization_code';
$result = $this->HttpRequestGet($url); $result = $this->HttpRequestGet($url);
if(!empty($result['openid'])) if(!empty($result) && !empty($result['openid']))
{ {
// 缓存SessionKey // 缓存SessionKey
$key = 'wechat_user_login_'.$result['openid']; $key = 'wechat_user_login_'.$result['openid'];
@ -279,7 +279,7 @@ class Wechat
// 网络请求 // 网络请求
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->_appid.'&secret='.$this->_appsecret; $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->_appid.'&secret='.$this->_appsecret;
$result = $this->HttpRequestGet($url); $result = $this->HttpRequestGet($url);
if(!empty($result['access_token'])) if(!empty($result) && !empty($result['access_token']))
{ {
// 缓存存储 // 缓存存储
$result['expires_in'] += time(); $result['expires_in'] += time();
@ -315,7 +315,7 @@ class Wechat
// 网络请求 // 网络请求
$url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$access_token.'&type='.$type; $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$access_token.'&type='.$type;
$result = $this->HttpRequestGet($url); $result = $this->HttpRequestGet($url);
if(!empty($result['ticket'])) if(!empty($result) && !empty($result['ticket']))
{ {
// 缓存存储 // 缓存存储
$result['expires_in'] += time(); $result['expires_in'] += time();