sendTemplateMessage模板消息发送函数 * * * * * ~~~ /** * 发送模板消息 * @param array $data 消息结构 * { * "touser":"OPENID", * "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY", * "url":"http://weixin.qq.com/download", * "topcolor":"#FF0000", * "data":{ * "参数名1": { * "value":"参数", * "color":"#173177" //参数颜色 * }, * "Date":{ * "value":"06月07日 19时24分", * "color":"#173177" * }, * "CardNumber":{ * "value":"0426", * "color":"#173177" * }, * "Type":{ * "value":"消费", * "color":"#173177" * } * } * } * @return boolean|array */ function sendTemplateMessage($data = []) { $wxObj = getWechatActiveObj(); $result = $wxObj->sendTemplateMessage($data); if (isset($result['errcode']) && $result['errcode'] == '0') { return $result; } if ($msg = wxApiResultErrorCode($wxObj->errCode)) { return ['errcode' => -1, 'errmsg' => $msg]; } return ['errcode' => -1, 'errmsg' => ' errCode:' . $wxObj->errCode . ' errMsg:' . $wxObj->errMsg]; } ~~~