/** * 向微信平台提交生成自定义菜单 * @author patrick <*****@*****.**> */ public function create() { $data = $this->get_data(); // 要先填写appid $map['public_id'] = get_token(); $info = D('Mpbase/MemberPublic')->where($map)->find(); if (empty($info['appid']) || empty($info['secret'])) { $this->error('请先配置公众号的appid和secret', U('Admin/Mpbase/index', 'id=' . $info['id'])); } $options = array('token' => 'uctoo', 'encodingaeskey' => $info['encodingaeskey'], 'appid' => $info['appid'], 'appsecret' => $info['secret']); $weObj = new TPWechat($options); $res = $weObj->createMenu($data); if ($res) { $this->success('发送菜单成功', U('Custommenu/index'), 3); } else { $this->success('发送菜单失败,错误的返回码是:' . $weObj->errCode . ', 错误的提示是:' . $weObj->errMsg, U('Custommenu/index'), 5); } }