Image and text code sharing in JAVA WeChat development Summary

Source: Internet
Author: User
Recently studied a bit, it is not very difficult to learn from the open source code of marker (www.yl-blog.com), modified a few small bugs (in the author's open source site left a word, see its open source site), and soon to realize the key logic: recently studied, it is not very difficult to learn from the open source code of marker (www.yl-blog.com, several bugs have been modified (for details, refer to the author's open-source website), and the key logic will soon be implemented:
1. developer verification
2. customize menus through program interfaces
3. send a welcome message after the user pays attention to it.
4. select topics of interest based on user input
5. send file messages and text messages
6. simulate a simple website template using a static webpage

The public account daydayup_it is under intense planning and development and is now available soon. The plan mainly provides quality educational resources, so stay tuned.

Prepare to sort out key technologies and post them for discussion.

I. developer verification, in fact, is mainly to write a Servlet, which is easy to handle with a little Web development experience.

Package org. marker. weixin. test; import java. io. IOException; import java. io. inputStream; import java. io. outputStream; import java. io. writer; import java. util. arrayList; import java. util. collections; import java. util. date; import java. util. list; import javax. servlet. servletException; import javax. servlet. http. httpServlet; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import org. apache. commons. logging. log; import org. apache. commons. logging. logFactory;/*** Servlet URL address used to process server requests: http://xxx/weixin/dealwith.do ** @ Author marker * @ blog www.yl-blog.com * @ weibo http://t.qq.com/wuweiit */Public class WinXinServlet extends HttpServlet {private static final long serialVersionUID = 1L; private static Log log = LogFactory. getLog (WinXinServlet. class); // TOKEN is the public static final String TOKEN = "YourToken" you set in the platform development mode;/*** process server verification * http://wallimn.iteye.com , 2014-09-11 */protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String signature = request. getParameter ("signature"); // encrypted signature String timestamp = request. getParameter ("timestamp"); // timestamp String nonce = request. getParameter ("nonce"); // random number String echostr = request. getParameter ("echostr"); // random string Writer out = response. getWriter (); System. ou T. println ("received verification request:"); System. out. println ("signature =" + signature); System. out. println ("timestamp =" + timestamp); System. out. println ("nonce =" + nonce); System. out. println ("echostr =" + echostr); if (signature = null | timestamp = null | nonce = null | echostr = null) {// if these parameters are NULL, an error is returned during sorting. Out. write ("parameter is null! ");} Else {// rewrite the totring method to obtain the concatenation string List of the three parameters.
 
  
List = new ArrayList
  
   
(3) {private static final long serialVersionUID = 2621444384256420433l; public String toString () {return this. get (0) + this. get (1) + this. get (2) ;}}; list. add (TOKEN); list. add (timestamp); list. add (nonce); Collections. sort (list); // sort String tmpStr = new MySecurity (). encode (list. toString (), MySecurity. SHA_1); // SHA-1 encrypted if (signature. equals (tmpStr) {out. write (echostr); // The request is successfully verified, and a random code} else {out. write ("check Error! ") ;}} Out. flush (); out. close ();}/*** handle various messages sent from the server, including text, images, geographic locations, music, etc. * http://wallimn.iteye.com, 2014-09-11 */protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {log.info ("received POST request:" + (new Date (); request. setCharacterEncoding ("UTF-8"); response. setContentType ("text/html; charset = utf-8"); InputStream is = request. getInputStream (); OutputStream OS = response. getOutputStream (); // TODO: write the processing logic of various information pushed by the platform }}
  
 

2. test the homepage effect and code of the website. with bootstrap, media queries are supported. when the mobile phone is horizontally viewed, the column will become 2*2 layout and index. jsp, which must be supported by JSTL. you can also remove it without affecting the effect. pay attention to the path of the connected file.

The above is the detailed content shared by the graphic code summarized by JAVA development. For more information, see other articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.