介绍:https://mp.weixin.qq.com/wiki(微信公众号官方的网址)、
//发送模板信息
$data = array(
'loadingAddr' => $logistics['loadingAddr'],
'unloadingAddr' => $logistics['unloadingAddr'],
'goodsName' => $logistics['goodsName'],
'openid' => $users['openid'],
'danhao' => $res['orderNo'],
'time' => date('Y-m-d H:i:s')
);
$rest = new \WeChat\Model\JieRuModel();
$rest->send_template_message($data);
public function send_template_message($data){
//模板消息(里面的选项具体根据提供的模板设置)
$template =
array(
'touser' => $data['openid'],//用户的openid
'template_id' => C('WECHAT.MOBAN_ID'),//模板id
'url' => '',//点击模板的跳转地址
'data' => array(
'first' => array(
'value' => '尊敬的客户您好',
'color' => '#000000',
),
'keyword1' => array(
'value' => $data['danhao'],
'color' => '#000000',
),
'keyword2' => array(
'value' => $data['goodsName'].",".$data['loadingAddr'].'-'.$data['unloadingAddr'].",业务员已开单,请及时取单",
'color' => '#000000',
),
'remark' => array(
'value' => $data['time'],
'color' => '#000000',
)
)
);
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$this->getAccessToken();
$data = json_encode($template);
$res = $this->request($url,true,'post',$data);
return json_decode($res, true);
}