1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\service\api;
- use app\service\ConfServiceFacade;
- use laytp\traits\Error;
- use think\facade\Cache;
- use think\facade\Config;
- use think\facade\Request;
- use EasyWeChat\Factory;
- class Mp{
- use Error;
- /**
- * 初始化
- * @param $token
- * @return bool
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function option($snsapi='snsapi_base')
- {
- $wechat = ConfServiceFacade::groupGet('system.wechat', true);
- $config = [
- 'app_id' => $wechat['appid'],
- 'secret' => $wechat['appsecret'],
- // 下面为可选项
- // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
- 'response_type' => 'array',
- // 'log' => [
- // 'level' => 'debug',
- // 'file' => __DIR__.'/wechat.log',
- // ],
- /**
- * OAuth 配置
- *
- * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login
- * callback:OAuth授权完成后的回调页地址
- */
- 'oauth' => [
- 'scopes' => [$snsapi],
- 'callback' => request()->domain() . SURL . '/index.php/api.wechat/notify',
- ],
- ];
- return Factory::officialAccount($config);
- }
- }
|