PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Laravel框架中通过EasyWeChat发送公众号模板消息大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

环境要求

使用COR_663_11845@poser安装:

$ 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',//发送后用户点击@L_675_6@的链接
        'miniprogram' => [ //与公众号绑定的小程序(选传)
                'appid' => 'xxxxxxx',//小程序id
                'pagepath' => 'pages/xxx',//跳转页面
        ],
        'data' => [
            'key1' => 'VALUE',
            'key2' => 'VALUE2',
            ...
        ],
    ]);

注意:如果参数url和miniprogram都传的话会优先@L_675_6@@L_509_8@miniprogram哦;

大佬总结

以上是大佬教程为你收集整理的Laravel框架中通过EasyWeChat发送公众号模板消息全部内容,希望文章能够帮你解决Laravel框架中通过EasyWeChat发送公众号模板消息所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: