请问php如何实现公众号模板消息推送给用户?
网友回复
先获取access_token然后接口推送模板数据,完整代码如下:
<?php var_dump(send_notice()); function send_notice() { $access_token = ''; $AppID = ""; $AppSecret = ""; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$AppID."&secret=".$AppSecret; $tokendata = curl_post($url); if (isset($tokendata['access_token'])) { $access_token = $tokendata['access_token']; }else{ return 'access_token获取失败'; } //模板消息 $json_template = json_tempalte(); $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token; $res = curl_post($url, urldecode($json_template)); var_dump($res); if ($res['errcode'] == 0) { return '发送成功'; } else { return '发送失败'; } } function ...
点击查看剩余70%