123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace addons\notice\library;
- use EasyWeChat\Factory;
- class Service
- {
- /**
- * 获取 easyWechat 公众号实例
- *
- * @return \EasyWeChat\OfficialAccount\Application
- */
- public static function getOfficialAccount()
- {
- $appId = get_addon_config('notice')['app_id'] ?? '';
- $secret = get_addon_config('notice')['secret'] ?? '';
- if (empty($appId)) {
- $config = get_addon_config('third');
- if ($config) {
- $appId = $config['wechat']['app_id'] ?? '';
- $secret = $config['wechat']['app_secret'] ?? '';
- }
- }
- if (empty($appId)) {
- $config = get_addon_config('epay');
- if ($config) {
- $appId = $config['wechat']['app_id'] ?? '';
- $secret = $config['wechat']['app_secret'] ?? '';
- }
- }
- $config = [
- 'app_id' => $appId,
- 'secret' => $secret,
- 'response_type' => 'array',
- ];
- $app = Factory::officialAccount($config);
- return $app;
- }
- }
|