123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Service\WechatPlatform;
- use EasyWeChat\Factory;
- use EasyWeChat\OpenPlatform\Application;
- use Illuminate\Support\Facades\Cache;
- class WechatPlatform
- {
- public static function buildApplication($componentInfo) {
- $config = [
- 'app_id' => $componentInfo->app_id, // 开放平台账号的 appid
- 'secret' => $componentInfo->secret, // 开放平台账号的 secret
- 'token' => $componentInfo->token, // 开放平台账号的 token
- 'aes_key' => $componentInfo->aes_key, // 明文模式请勿填写 EncodingAESKey
- ];
- $app = Factory::openPlatform(array_merge($config, config('easywechat')));
- $app->rebind('cache',Cache::store('redis'));
- return $app;
- }
- /**
- * @param $app Application
- * @param $appid
- * @param $refreshToken
- * @return \EasyWeChat\OfficialAccount\Application
- */
- public static function officialAccount($app, $appid, $refreshToken) {
- return $app->officialAccount($appid, $refreshToken);
- }
- }
|