Fork me on GitHub

EasyWeChat报错Failed to cache access token.

Failed to cache access token.

调用image
报错
image

解决办法

方案一: 安装 Symfony Cache

composer require symfony/cache

查看/tmp下面的symfony-cache是否之前被其他用户创建,如果被其他用户创建则无权限,需要删除。
image

方案二: 手动指定缓存目录

        $config = [
            'app_id'        => "app_id",
            'secret'        => "secret",
            'aes_key'       => '',  // 明文模式可留空
            'response_type' => 'array',

            // ✅ 指定缓存驱动
            'cache' => new FilesystemAdapter(
                'easywechat',   // 缓存命名空间
                1500,           // 缓存有效时间(秒)
                runtime_path() . 'easywechat-cache' // 缓存路径
            ),
        ];
        $this->app = Factory::officialAccount($config);

在runtime/easywechat-cache下面

posted @ 2025-09-09 10:36  秋夜雨巷  阅读(43)  评论(0)    收藏  举报