123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Services\Common;
- use EasyWeChat\Factory;
- use EasyWeChat\OfficialAccount\Application;
- /**
- * 微信服务.从这里可以获取公众号,小程序实例
- * Class WechatService
- * @package App\Services\Common
- */
- class WechatService
- {
- protected $config = [];
- /**
- * WechatService constructor.
- */
- public function __construct()
- {
- $this->config['log'] = config('wechat.log');
- }
- /**
- * 返回公众号实例
- * @param null $subsite_id
- * @return Application
- */
- public function getOfficialAccount($subsite_id = null)
- {
- $this->config['app_id'] = subsite_config('aix.system.oauth.wechat_official.app_id', null, $subsite_id);
- $this->config['secret'] = subsite_config('aix.system.oauth.wechat_official.app_secret', null, $subsite_id);
- $this->config['token'] = subsite_config('aix.system.oauth.wechat_official.app_token', null, $subsite_id);
- $this->config['aes_key'] = subsite_config('aix.system.oauth.wechat_official.aes_key', null, $subsite_id);
- return Factory::officialAccount($this->config);
- }
- /**
- * 获取微信开放平台的网站应用实例.(用于电脑端网站登录,使用开放平台中创建的网站的appid与appsecret
- * @return Application
- */
- public function getOpenAccount()
- {
- $this->config['app_id'] = config('aix.system.oauth.wechat_open.app_id');
- $this->config['secret'] = config('aix.system.oauth.wechat_open.app_secret');
- return Factory::officialAccount($this->config);
- }
- public function getPayOfficialAccount()
- {
- $this->config['app_id'] = config('aix.system.pay.wechat.appid');
- $this->config['secret'] = config('aix.system.pay.wechat.secret_key');
- return Factory::officialAccount($this->config);
- }
- }
|