Laravel框架中通过EasyWeChat发送公众号模板消息
作者:互联网
环境要求
- PHP >= 7.0
- PHP cURL 扩展
- PHP OpenSSL 扩展
- PHP SimpleXML 扩展
- PHP fileinfo 拓展
使用composer安装:
$ composer require overtrue/wechat:~4.0 -vvv
然后就开始使用咯:
use EasyWeChat\Factory; $config = [ 'app_id' => 'wx3cf0f39249eb0exx',//公众号app_id 'secret' => 'f1c242f4f28f735d4687abb469072axx',//公众号secret 'log' => [ //生成错误日志 'level' => 'debug', 'file' => '/tmp/esaywechat.log', ] ]; $app = Factory::officialAccount($config); $app->template_message->send([ 'touser' => 'user-openid',//用户openid 'template_id' => 'template-id',//发送的模板id 'url' => 'https://easywechat.org',//发送后用户点击跳转的链接 'miniprogram' => [ //与公众号绑定的小程序(选传) 'appid' => 'xxxxxxx',//小程序id 'pagepath' => 'pages/xxx',//跳转页面 ], 'data' => [ 'key1' => 'VALUE', 'key2' => 'VALUE2', ... ], ]);
注意:如果参数url和miniprogram都传的话会优先跳转小程序miniprogram哦;
标签:Laravel,app,EasyWeChat,miniprogram,template,跳转,PHP,id,模板 来源: https://www.cnblogs.com/wxy0126/p/11805179.html