创建自定义菜单
使用 createMenu($menu);可以创建公众号自定义菜单,代码如下:
<?php class wxController extends grace{ public function index(){ $gracewechat = tool('graceWeChat'); $menu = ' { "button": [ { "type":"click", "name":"php编程", "key":"KEY01" }, { "name":"html", "sub_button": [ { "type":"view", "name":"网易", "url":"http://www.163.com/" }, { "type":"view", "name":"腾讯", "url":"http://www.qq.com/" } ] }, { "name":"更多", "sub_button": [ { "type":"view", "name":"我的..", "url":"http://wx.hcoder.net/demo/my.php" }, { "type":"view", "name":"支付..", "url":"http://wx.hcoder.net/demo/pay.php" } ] } ] }'; $gracewechat->createMenu($menu); } }
识别菜单点击
$gracewechat->getMsg(); if($gracewechat->msgType == 'event' && $gracewechat->event == 'CLICK'){ $gracewechat->reTextMsg('点击参数:'. $gracewechat->msg->EventKey); }