//菜单处理地理位置信息 func LocationEventSelectMessageHandle(w http.ResponseWriter, r *mp.Request) { location := menu.GetLocationSelectEvent(r.MixedMsg) fmt.Println(location) resp := response.NewText(location.FromUserName, location.ToUserName, location.CreateTime, location.SendLocationInfo.Label) mp.WriteRawResponse(w, r, resp) fmt.Println("LocationEventSelectMessageHandle") }
//====自定义事件推送==== func EventMessageHandler(w http.ResponseWriter, r *mp.Request) { text := menu.GetClickEvent(r.MixedMsg) location := menu.GetLocationSelectEvent(r.MixedMsg) // key := "click_count_"+text.EventKey var content string switch text.EventKey { case "V1001_TODAY_MUSIC": content = text.EventKey + "你点击了一下" case "V1001_GOOD": content = text.EventKey + "收到您的点赞,我非常高兴" case "V1001_IMG": //回复图片信息 resp := response.NewImage(text.FromUserName, text.ToUserName, text.CreateTime, mediaId) mp.WriteRawResponse(w, r, resp) case "V1001_LOCATION": content = text.Event + "text - 地理位置上报成功" fmt.Println(content) fmt.Println(location.SendLocationInfo.Label) fmt.Println(location.SendLocationInfo.PoiName) default: content = text.EventKey + "oh ,what is wrong" } switch location.EventKey { case "V1001_LOCATION": fmt.Println(location.EventKey) content = location.Event + " location - 上报地理位置成功" fmt.Println(location.SendLocationInfo.Label) fmt.Println(location.SendLocationInfo.PoiName) default: fmt.Println(location.EventKey) content = "location - 上报地理位置失败" } // Incr(key) resp := response.NewText(text.FromUserName, text.ToUserName, text.CreateTime, content) mp.WriteRawResponse(w, r, resp) // 明文模式 }