/**
?* 创建菜单
?*/
public static boolean createMenu(String params) {
String accessToken = WeChat.getAccessToken();
String jsonStr = HttpKit.post("/cgi-bin/menu/create?access_token=" + accessToken, params);
Map<String, Object> map = JSON.parseObject(jsonStr,Map.class);
return "0".equals(map.get("errcode").toString());
}
public static void main(String[] args) {
String s = "{\"button\":[{\"name\":\"休闲娱乐\",\"sub_button\":[{\"type\":\"click\",\"name\":\"笑话大全\",\"key\":\"m_joke\"},{\"type\":\"click\",\"name\":\"内涵段子\",\"key\":\"m_duanzi\"},{\"type\":\"click\",\"name\":\"爆笑图片\",\"key\":\"m_laughImg\"}]},{\"name\":\"实用工具\",\"sub_button\":[{\"type\":\"click\",\"name\":\"天气查询\",\"key\":\"m_weather\"},{\"type\":\"click\",\"name\":\"公交查询\",\"key\":\"m_bus\"},{\"type\":\"click\",\"name\":\"功能菜单\",\"key\":\"m_sysmenu\"}]},{\"name\":\"消息示例\",\"sub_button\":[{\"type\":\"click\",\"name\":\"关于企特\",\"key\":\"m_about\"},{\"type\":\"click\",\"name\":\"图文消息\",\"key\":\"m_imgmsg\"},{\"type\":\"click\",\"name\":\"音乐消息\",\"key\":\"m_musicmsg\"}]}]}";
if(createMenu(s)){
LOGGER.info("菜单创建成功!");
}else{
LOGGER.info("菜单创建失败!");
}
}
mian 方法直接运行,简单吧!