|
|
@@ -20,6 +20,7 @@ use app\common\model\notice\NoticeSetting;
|
|
|
use EasyWeChat\Kernel\Exceptions\Exception;
|
|
|
use EasyWeChat\OfficialAccount\Application;
|
|
|
use think\facade\Log;
|
|
|
+use WpOrg\Requests\Requests;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -73,7 +74,22 @@ class WeChatOaService
|
|
|
return $config;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @notes 只获取微信用户openid信息
|
|
|
+ * @return array
|
|
|
+ * @throws Exception
|
|
|
+ * @author 段誉
|
|
|
+ * @date 2023/2/27 12:03
|
|
|
+ */
|
|
|
+ public function getOpenIdByCode(string $code)
|
|
|
+ {
|
|
|
+ $config = WeChatConfigService::getOaConfig();
|
|
|
+ $url = 'https://api.weixin.qq.com/sns/oauth2/access_token';
|
|
|
+ $url .= '?appid=' . $config['app_id'] . '&secret=' . $config['secret'] . '&code=' . $code;
|
|
|
+ $url .= '&grant_type=authorization_code';
|
|
|
+ $requests = Requests::get($url);
|
|
|
+ return json_decode($requests->body, true);
|
|
|
+ }
|
|
|
/**
|
|
|
* @notes 公众号-根据code获取微信信息
|
|
|
* @param string $code
|