1、创建菜单
//创建菜单 public function createMenu(){ $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="; $url.=$this->getacctoken(); //目前自定义菜单最多包括3个一级菜单,每个一级菜单最多包含5个二级菜单。一级菜单最多4个汉字, //二级菜单最多7个汉字,多出来的部分将会以“...”代替。请注意,创建自定义菜单后,由于微信客户 //端缓存,需要24小时微信客户端才会展现出来。建议测试时可以尝试取消关注公众账号后再次关注, //则可以看到创建后的效果。 $post_data=‘{ "button":[ { "type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" }, { "type":"click", "name":"歌手简介", "key":"V1001_TODAY_SINGER" }, { "name":"菜单", "sub_button":[ { "type":"view", "name":"搜索", "url":"http://www.soso.com/" }, { "type":"view", "name":"视频", "url":"http://v.qq.com/" }, { "type":"click", "name":"赞一下我们", "key":"V1001_GOOD" }] }] }‘; $result = $this->cpost($url,$post_data); echo "errmsg = ".$result[‘errmsg‘]; }
2、查询、删除菜单
//查询菜单 public function queryMenu(){ $url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token="; $url.=$this->getacctoken(); $result = $this->cget($url ); echo "resultStr = ".print_r($result); } //删除菜单 public function delMenu(){ $url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token="; $url.=$this->getacctoken(); $result = $this->cget($url); echo "errmsg = ".$result[‘errmsg‘]; }
时间: 2024-10-14 05:35:35