//消息推送
public function sendTemplateMsg(){
/**
* 可以申请到15个模板
* 一个账号的当日的模板消息次数不能超过10万次
* 1.获取到access_token
*/
$access_token = getWxAccessToken();
$array = array(
$url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN".$access_token
);
//2.组装数组
// {
// "touser":"OPENID",
// "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
// "url":"http://weixin.qq.com/download",
// "miniprogram":{
// "appid":"xiaochengxuappid12345",
// "pagepath":"index?foo=bar"
// },
// "data":{
// "first": {
// "value":"恭喜你购买成功!",
// "color":"#173177"
// },
// "keyword1":{
//
// }
// }
//
// }
$array = array(
'touser' => 'wx78c448412898b330',//微信用户的openid
'template_id' => 'Nu4So_l8OdHJi4loOY_SCKh8fZdrq1p32oQ7ynq9dZg',//模板id
'url' => 'http://www.imooc.com',
'data' => array(
'name' =>array('value'=>'hello','color'=>"#173177"),
'money' =>array('value'=>100,'color'=>"#173177"),
'date' =>array('value'=>date('Y-m-d H:i:s'),'color'=>"#173177"),
),
);
//3.将数组->json
$postJson = json_encode($array);
//4.调用curl函数
$res = $this->http_curl($url,'post','json',$postJson);
//var_dump($res);
}