Yan Yan Springboot development WeChat official account (two)

Keywords: SpringBoot

Yan Yan Springboot development WeChat official account (two)

Message reception and reply:

  • Text message
  • Graphic message
  • information about the music
  • Picture message
  • Geolocation message
  • Link message
  • Audio message
  • Event push

Text message

respContent = "Welcome to pay attention "+logo+" ! We will try our best to provide you with more wonderful content!"
                            + "\n\n Reply 1 , 2 , 3 ,... See more!"; 

Graphic message

Article article = new Article();
                    article.setTitle("Yan Hui - Recommended cochlea");
                    article.setDescription("My principle of doing wechat business is:" + "①Have products, use them first, use them well, share them with friends" + "②I don't sell. I make circles every day. I just want to tell my friends that I've been doing it"
                            + "③Don't exaggerate. Ask me how good things are. I'll tell you");

information about the music

Music music = new Music();
                        music.setTitle("I love him");
                        music.setDescription("I love him-Ding Ding");

Picture message

// Get image address
                String picUrl = requestMap.get("PicUrl");
                // Face detection
                String detectResult = FaceService.detect(picUrl);
                return MessageUtil.messageToXml(textMessage);

Geolocation message

// Longitude and latitude sent by the user  
                String lng = requestMap.get("Location_Y");  
                String lat = requestMap.get("Location_X");  
                // Latitude and longitude after coordinate transformation  
                String bd09Lng = null;  
                String bd09Lat = null;  
                // Call interface to convert coordinates  
                UserLocation userLocation = BaiduMapUtil.convertCoord(lng, lat);  
                if (null != userLocation) {  
                    bd09Lng = userLocation.getBd09Lng();  
                    bd09Lat = userLocation.getBd09Lat();  
//                logger.info("lng= " + lng + "; lat= " + lat);  
//                logger.info("bd09Lng= " + bd09Lng + "; bd09Lat= " + bd09Lat);  

                // Save user geographic location  
//                int count = userLocationDao.saveUserLocation(fromUserName, lng, lat, bd09Lng, bd09Lat);
                com.yanhui.weixin.pojo.UserLocation userLocation2 = new com.yanhui.weixin.pojo.UserLocation(null,fromUserName, lng, lat, bd09Lng, bd09Lat);
                int count = userLocationMapper.insert(userLocation2);

Link message

 respContent = "You are sending a link message!";  

Audio message

 respContent = "You are sending audio messages!";  

Event push

 respContent = "you are sending event push! "; -- use the interceptor to achieve user focus to obtain user information, return to focus on language and text, and cancel the focus. Next section begins... Welcome to...

Note: all source code is required. QQ490647751 reply can be added to the "WeChat official account (two)" developed by Yan Yan Springboot.

Posted by Sinemacula on Sat, 02 May 2020 10:31:57 -0700