EasyWechat 公众号,小程序模板消息发送

 公众号模板消息发送

$config = [
    'app_id' => '你的公众号appid',
    'secret' => '你的公众号secret',
];
$app = Factory::officialAccount($config);
$app->template_message->send([
    'touser' => '用户openId',
    'template_id' => '您的模板id',
    'url' => 'https://easywechat.org', //选填
    'data' => [
        'first' => ['您有新的订单订单号:123456', '#FF0000'],
        'keyword1' => '测试',
        'keyword2' => '测试',
        'keyword3' => '测试',
        'keyword4' => '测试',
        'keyword5' => '测试',
        'keyword6' => '测试',
        'keyword7' => ['测试', '#FF0000'],
        'remark' => ['测试', '#00FF00'],
    ],
]);

小程序订阅消息发送

$config = [
    'app_id' => '小程序APPID',
    'secret' => '小程序secret',
];
$app = Factory::miniProgram($config);
$data = [
    'template_id' =>'订阅消息ID',
    'touser' => '用户openid',
    'page' => '',
    'data' => [ 
        'character_string1' =>123,
        'thing2' => '测试',
        'amount4' => 90,
        'thing5' => '测试',
        'time17' => date('Y-m-d'),
    ],
];

return json( $app->subscribe_message->send($data));

 小程序授权

wx.requestSubscribeMessage({
    tmplIds: ['订阅消息ID'],
    success(res) {
        console.log(res)
    }
})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值