wechat4j
What is wechat4j?
wechat develop framework for java (Wechat development framework JAVA version, the simplest and easiest to use Wechat development framework)
wechat4j can be used What to do?
wechat4j is a jar package that helps you develop WeChat applications. Using it, you can develop WeChat public account applications in just a few seconds without paying attention to too much detail.
wechat4j Quick Start
You can download the wechat4j sample project and then modify it based on it. If you want to build it yourself, you can use wechat4j to build a WeChat development environment in just two steps.
Create a web project and import jdk and related web project jar packages.
Download the wechat4j.jar package, download address wechat4j download.
Create the wechat4j configuration file, create the wechat4j.properties file in the src directory (java root directory), and configure the relevant information of your WeChat official account. The content is as follows:
#you server url wechat.url= #you wechat token wechat.token=token #message secret key,if don't set then message is cleartext wechat.encodingaeskey= #wechat appid wechat.appid=appid #wechat app secret wechat.appsecret=secret #wechat access token server ,when you save in db,must implement you server class #this class must extend org.sword.wechat4j.token.DbAccessTokenServer #if no this property,then token server is default memery accesstoken server() wechat.accessToken.server.class= #jsapi_ticket customer server class name, #this class must extend org.sword.wechat4j.token.server.CustomerServer #if no this property,then ticket server is default memery ticket server wechat.ticket.jsapi.server.class=
You can also find the wechat4j.properties.sample file in the META-INF directory of the jar package, copy it to the src directory and modify the name. For the meaning of the configuration items in the wechat4j.properties configuration file, see Interpretation of the wechat4j configuration file
After the above steps, your WeChat project is completely set up.
wechat4j operating environment
The minimum java operating environment required by wechat4j is jdk1.6
wechat4j.jar’s dependent jar package
commons-codec.jar 1.3 or above
commons-lang3.jar
log4j.jar 1.2 or above
fastjson-1.2.0.jar
fluent-hc-4.3.6.jar (httpclient dependency)
httpclient-4.3.6.jar
httpcore-4.3.3.jar (httpclient dependency)
servlet-api.jar If you It is a web project. Importing packages that support web projects will include, for example, the tomcat package
Develop your own WeChat application
After the wechat4j development environment is set up, You can start developing your own WeChat application. For example, I have a WeChat account whose token is lejian. Let’s use her as an example to illustrate.
Create your own public account service class
To create your own WeChat public account service class, you need to inherit the WechatSupport class of wechat4j, and then implement its abstract method. The following uses text message processing as an example
public class Lejian extends WechatSupport{public Lejian(HttpServletRequest request, String token) {super(request, token); }@Overrideprotected void onText() {this.wechatRequest.getFromUserName(); String content = "test ok";responseText(content); } }
onText() in the above code is an abstract method of WechatSupport, which requires your own class to implement, indicating the processing of text messages. In the example, it is receiving After receiving the user's message, return the "test ok" text message to the user.
Create WeChat service address
Create WeChat service address (your own server address configured in WeChat public platform) servlet class. If it is springmvc, create the corresponding controller, if it is struts, create the corresponding action class. An example of the servlet class is as follows:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Lejian lejian = new Lejian(request, TOKEN); String result = lejian.execute(); response.getOutputStream().write(result.getBytes()); }protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Lejian lejian = new Lejian(request, TOKEN); String result = lejian.execute(); response.getOutputStream().write(result.getBytes()); }
After the above two steps, your WeChat service can be run
More introduction to the java WeChat development framework wechat4j For tutorials and related articles, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!
