直接看微信官方文档然后写代码就行了。。
记录一下:
public function tongzhi(){
$tmpid = 'NFJ2jiOFNrfwGaab7ji6lEUtl233mq9lKptB-CxoEwI';
$reurl = $this -> get_url();
$url = 'https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid='.C('APPID').'&scene=1&template_id='.$tmpid.'&redirect_url='.urlencode($reurl).'#wechat_redirect';
if (!isset($_GET['openid'])) {
redirect($url);
}else{
dump($_REQUEST);
}
}

确认之后收到这些参数保存起来,发消息的时候要用

public function sendtongzhi(){ $e = A("Weixin")->senddingyuemsg(1,'oFV_Ut-mQYP-tkOcxxxxxxx2Gpxc','NFJ2jiOFNxxxxlEUtl233mq9lKptB-CxoEwI','http://shanmao.me','测试一下标题','测试一下内容啦啦啦啦啦'); dump($e); }
这是消息发送代码。
如果公众号是已关注的则会收到这样的消息:

没关注的时候是这样的:
