require './vendor/autoload.php';
use EasyWeChat\Factory;
$config = [
'app_id' => 'wx899695ec',
'secret' => 'f9fd4df0f68a0c07',
'token' => 'xlL1ItapFshFhA88Z8Ai5AIYzA',
'aes_key' => '', //明文模式下为空
'response_type' => 'array',
];
$app = Factory::officialAccount($config);
$result = $app->template_message->send([
'touser' => 'oS3TrsvDsvnF77BNNuMTj0FRi9g8',
'template_id' => 'Vm8N6Avj-rVlNx1s8GsUBgdTPmX4Q7zYfJNJ2PcXyLA',
'url' => 'http://demo.chinaportrait.org/',
'data' => [
'first' => array('value' => '您好!', 'color' => "#FF0000"),
'keyword1' => array('value' => '2022年', 'color' => '#FF0000'), //keyword需要与配置的模板消息对应
'keyword2' => array('value' => '100元', 'color' => '#FF0000'),
'remark' => array('value' => '感谢!', 'color' => '#FF0000')
]
]);
// var_dump($result);
if($result['errcode']==0){
echo '发送成功';
}else{
echo '发送失败';
}
Easywechat实现模版推送
最新推荐文章于 2023-10-26 13:20:16 发布