这个是返回打印出来的,
下面是我的代码
// 创建自定义菜单
func CreatMenu() {
token, _ := GetAccesstoken()
deleurl := "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" + token
response, err := http.Get(deleurl)
if err == nil {
fmt.Println("菜单删除正确")
fmt.Println(response)
} else {
fmt.Println("删除菜单错误")
fmt.Println(response)
}
//https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
//读取jsonfile
content, err := ioutil.ReadFile("./common/menu.json")
if err != nil {
log.Fatal("Error when opening file: ", err)
}
//拼接路由
createurl := "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + token
payload := strings.NewReader(string(content))
req, _ := http.NewRequest("POST", createurl, payload)
req.Header.Add("Content-Type", "application/json")
response, err = http.DefaultClient.Do(req)
if err == nil {
fmt.Println("菜单设置正确")
fmt.Println(response)
} else {
fmt.Printf("设置菜单错误")
}
}