微擎模板消息
2019-04-24 本文已影响0人
StevenQin
sendTplNotice
https://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1016
sendTplNotice($touser, $template_id, $postdata, $url = '', $topcolor = '#FF683F')
$url
和$topcolor
两个参数不是必填的
案例:
- 前台函数
//发送模板消息
public function doMobileSendtpl()
{
global $_W,$_GPC;
// 取得openID信息
$userinfo = mc_oauth_userinfo($_W['uniacid']);
$data = array(
'first' => array(
'value' => "健康监测回复!",
'color' => '#ff510'
),
'keyword1' => array(
'value' => $userinfo['nickname'],
'color' => '#ff510'
),
'keyword2' => array(
'value' => "半封闭管理",
'color' => '#ff510'
),
'keyword3' => array(
'value' => "晚餐后2小时",
'color' => '#ff510'
),
'keyword4' => array(
'value' => "血糖:4.8",
'color' => '#ff510'
),
'keyword5' => array(
'value' => "加油哦",
'color' => '#ff510'
),
);
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx26655f11eb02e195&redirect_uri=http%3A%2F%2Fwx%2Eraycare%2Enet%2Findex%2Easp&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
$account_api = WeAccount::create();
var_dump($userinfo);
$result = $account_api->sendTplNotice($userinfo['openid'], 'CEvpRllQPI-dVBOLSFvPBTXT87iu0V6bpEt1Zu_2NLQ', $data, $url);
}
- 路由
http://mall.raycare.net/app/./index.php?i=5&c=entry&do=sendtpl&m=health_moniter
-
在微信环境中测试