飞哥教你微信公众号开发-2-自定义菜单

自定义菜单能够帮助公众号丰富界面,让用户更好更快地理解公众号的功能。开启自定义菜单后,公众号界面如图所示:

飞哥教你微信公众号开发-2-自定义菜单_第1张图片
       同样先看开发文档         自定义菜单


package com.fly.wechat.mpdemo.api.session;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.fly.wechat.mpdemo.api.BaseController;
import com.fly.wechat.mpdemo.config.MchInfo;
import com.fly.wechat.mpdemo.model.Button;
import com.fly.wechat.mpdemo.model.Matchrule;

@Controller
@RequestMapping("/menu")
public class MenuController extends BaseController{
	
	public String GETMENU_URL="https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN";
	
	public String CREATEMENU_URL="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
	
	public String CREATEPMENU_URL="https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=ACCESS_TOKEN";
	
	public String DELETEMENU_URL="https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN";
	
	public String GETCURRENTMENU_URL="https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=ACCESS_TOKEN";
	/**
	 * 自定义菜单查询接口
	 * @return
	 * @throws Throwable
	 */
	@ResponseBody
	@RequestMapping("/getMenu.do")
	public String getMenu() throws Throwable {
		return httpGet(GETMENU_URL.replace("ACCESS_TOKEN", MchInfo.getAccessToken()), "", d_timeout);
	}
	/**
	 * 自定义菜单创建接口
	 * @return
	 * @throws Throwable
	 */
	@ResponseBody
	@RequestMapping("/createMenu.do")
	public String createMenu() throws Throwable {
		List





你可能感兴趣的:(微信公众号开发)