|
@@ -86,7 +86,7 @@ class WechatService extends BaseService
|
|
|
*/
|
|
*/
|
|
|
public static function auth()
|
|
public static function auth()
|
|
|
{
|
|
{
|
|
|
- $userInfo = WechatService::getUserInfo('', true);
|
|
|
|
|
|
|
+ $userInfo = WechatService::getWechatInfo('', true);
|
|
|
$openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
$openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
$cacheKey = 'weixin:init:'.get_client_ip().'_'.$openid;
|
|
$cacheKey = 'weixin:init:'.get_client_ip().'_'.$openid;
|
|
|
if (empty($userInfo) || empty($openid)) {
|
|
if (empty($userInfo) || empty($openid)) {
|
|
@@ -213,8 +213,7 @@ class WechatService extends BaseService
|
|
|
$expire = isset($tokenData['expire']) ? intval($tokenData['expire']) : 0;
|
|
$expire = isset($tokenData['expire']) ? intval($tokenData['expire']) : 0;
|
|
|
$token = isset($tokenData['token']) ? trim($tokenData['token']) : '';
|
|
$token = isset($tokenData['token']) ? trim($tokenData['token']) : '';
|
|
|
if (($expire && $expire < time()) || empty($token)) {
|
|
if (($expire && $expire < time()) || empty($token)) {
|
|
|
-
|
|
|
|
|
- //$tokenData = WechatService::getTempAccessToken($key, true);
|
|
|
|
|
|
|
+ $tokenData = WechatService::getTempAccessToken($key, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($key) {
|
|
if ($key) {
|
|
@@ -276,7 +275,7 @@ class WechatService extends BaseService
|
|
|
* @param string $openid 获取的用户OPENID,默认当前用户
|
|
* @param string $openid 获取的用户OPENID,默认当前用户
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
- public static function getUserInfo($curOpenid = '', $saveData = false)
|
|
|
|
|
|
|
+ public static function getWechatInfo($curOpenid = '', $saveData = false)
|
|
|
{
|
|
{
|
|
|
$code= request()->get('code','');
|
|
$code= request()->get('code','');
|
|
|
$tokenData = WechatService::getTempAccessToken();
|
|
$tokenData = WechatService::getTempAccessToken();
|
|
@@ -288,7 +287,7 @@ class WechatService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$openid = $curOpenid ? $curOpenid : $openid;
|
|
$openid = $curOpenid ? $curOpenid : $openid;
|
|
|
- $url = sprintf(self::$apiUrl['userInfo'], $token, $openid);
|
|
|
|
|
|
|
+ $url = sprintf(self::$apiUrl['wxInfo'], $token, $openid);
|
|
|
RedisService::set("caches:userInfo:request_{$openid}",['token'=> $tokenData,'url'=> $url], 600);
|
|
RedisService::set("caches:userInfo:request_{$openid}",['token'=> $tokenData,'url'=> $url], 600);
|
|
|
$result = httpRequest($url);
|
|
$result = httpRequest($url);
|
|
|
$errcode = isset($result['errcode']) ? $result['errcode'] : '';
|
|
$errcode = isset($result['errcode']) ? $result['errcode'] : '';
|