simplecms / wechat
微信小程序
1.0.1
2024-07-27 07:01 UTC
Requires
- php: >=8.0
- w7corp/easywechat: >=6.7
This package is auto-updated.
Last update: 2025-02-27 08:07:07 UTC
README
仅处理code openid 及推送、后端服务
安装
composer require simplecms/wechat
配置.env
WECHAT_PROGRAM_APPID="小程序APPID" WECHAT_PROGRAM_SECRET="小程序secret"
推送消息
use SimpleCMS\Wechat\Facades\MiniProgram; //发送推送消息 return MiniProgram::postMessage(openId:'xxxx',templateId:'xxxxx',data:[]);
监听后端消息
在App\Providers\AppServiceProvider
的boot中增加事件监听
use Illuminate\Support\Facades\Event; //监听登录 //前端URL: /api/wechat/mini/token/{code} Event::listen('plugin.wechat.code2session',function(string $openId){ //...Todo.. }); //监听后端 //前端URL: /api/wechat/serve Event::listen('plugin.message',function($event='subscribe', $message, \Closure $next){ //...Todo.. });
Facades
use SimpleCMS\Wechat\Facades\MiniProgram; #地理位置
其他说明
更多操作参考IDE提示