封裝模板消息 時 $access_token = getWxAccessToken(); getWxAccessToken這個方法在哪里調(diào)用的 沒有講到呀
//消息推送
? ? public function sendTemplateMsg(){
? ?
/**
* 可以申請到15個模板
* 一個賬號的當(dāng)日的模板消息次數(shù)不能超過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.組裝數(shù)組
// {
// ? ? ? ? ? ?"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://idcbgp.cn',
'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.將數(shù)組->json
$postJson = json_encode($array);
//4.調(diào)用curl函數(shù)
$res = $this->http_curl($url,'post','json',$postJson);
//var_dump($res);
? ?}?