Ejemplo n.º 1
0
Archivo: main.go Proyecto: kekek/test
func CreateMenu(w http.ResponseWriter, r *http.Request) {
	var subButtons = make([]menu.Button, 2)

	subButtons[0].SetAsViewButton("搜索", "http://www.soso.com/")
	subButtons[1].SetAsClickButton("赞一下我们", "V1001_GOOD")

	var testButtons = make([]menu.Button, 3)
	testButtons[0].SetAsClickButton("今日歌曲", "V1001_TODAY_MUSIC")
	testButtons[1].SetAsClickButton("来一张图片", "V1001_IMG")
	testButtons[2].SetAsLocationSelectButton("地理位置", "V1001_LOCATION")

	var mn menu.Menu
	mn.Buttons = make([]menu.Button, 3)
	mn.Buttons[0].SetAsSubMenuButton("test", testButtons)
	mn.Buttons[1].SetAsViewButton("视频", "http://v.qq.com/")
	mn.Buttons[2].SetAsSubMenuButton("子菜单", subButtons)

	menuClient := (*menu.Client)(mpClient)
	if err := menuClient.CreateMenu(mn); err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("ok")
	w.Write([]byte("create menu:success"))
}
Ejemplo n.º 2
0
Archivo: main.go Proyecto: kekek/test
func createMenu(w http.ResponseWriter, r *http.Request) {

	log.Println("create menu: begin...")
	fmt.Println("%v", r.Body)
	var AccessTokenServer = mp.NewDefaultAccessTokenServer(AppId, AppSecret, nil) // 一個應用只能有一個實例
	var mpClient = mp.NewClient(AccessTokenServer, nil)

	var subButtons = make([]menu.Button, 2)

	subButtons[0].SetAsViewButton("搜索", "http://www.soso.com/")
	subButtons[1].SetAsClickButton("赞一下我们", "V1001_GOOD")

	var testButtons = make([]menu.Button, 2)
	testButtons[0].SetAsClickButton("今日歌曲", "V1001_TODAY_MUSIC")
	testButtons[1].SetAsClickButton("来一张图片", "V1001_IMG")

	var mn menu.Menu
	mn.Buttons = make([]menu.Button, 3)
	mn.Buttons[0].SetAsSubMenuButton("...", testButtons)
	mn.Buttons[1].SetAsViewButton("视频", "http://v.qq.com/")
	mn.Buttons[2].SetAsSubMenuButton("子菜单", subButtons)

	menuClient := (*menu.Client)(mpClient)
	if err := menuClient.CreateMenu(mn); err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("ok")
	w.Write([]byte("create menu:success"))
}
Ejemplo n.º 3
0
func main() {
	beego.Run()
	var mn menu.Menu
	mn.Buttons = make([]menu.Button, 3)
	mn.Buttons[0].SetAsClickButton("我买果", "V1001_TODAY_MUSIC")
	mn.Buttons[1].SetAsViewButton("我卖果", "http://v.qq.com/")

	var subButtons = make([]menu.Button, 2)
	subButtons[0].SetAsViewButton("京郊水果", "http://www.soso.com/")
	subButtons[1].SetAsClickButton("进口精品", "V1001_GOOD")

	mn.Buttons[2].SetAsSubMenuButton("加入我们", subButtons)

	clt := menu.Client{Client: mpClient}
	if err := clt.CreateMenu(mn); err != nil {
		Log.Info(err.Error())
		return
	}
	Log.Info("菜单创建完成")

}
Ejemplo n.º 4
0
func CreateMenu() {
	AccessTokenServer := mp.NewDefaultAccessTokenServer(APPID, APPSECRET, nil) // 一個應用只能有一個實例
	WechatClient := mp.NewClient(AccessTokenServer, nil)
	clt := menu.NewClient(WechatClient.AccessTokenServer, WechatClient.HttpClient)
	clt.DeleteMenu()

	var mn menu.Menu
	mn.Buttons = make([]menu.Button, 3)
	mn.Buttons[0].SetAsViewButton("种犬展示", "http://test.lichengsoft.com/dogs")
	mn.Buttons[1].SetAsViewButton("待售幼犬", "http://test.lichengsoft.com/pups")

	var subButtons = make([]menu.Button, 3)
	subButtons[0].SetAsViewButton("我要留言", "http://test.lichengsoft.com/comment")
	subButtons[1].SetAsViewButton("关于灵睿", "http://test.lichengsoft.com/about")
	subButtons[2].SetAsViewButton("登录灵睿", "http://test.lichengsoft.com/signin")

	mn.Buttons[2].SetAsSubMenuButton("更多信息", subButtons)

	if err := clt.CreateMenu(mn); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("menu reset success !")
}