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 '发送失败';
}
版权声明:本文为yangguofu0324原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。