赞
踩
【实例简介】调用图灵机器人借口,在微信实现智能回复功能
【实例截图】
【核心代码】
package servlet;
import org.sword.wechat4j.token.AccessTokenProxy;
import service.Lejian;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by Administrator on 2016/11/16.
*/
public class WechatServlet extends HttpServlet {
public WechatServlet(){
super();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.print("hello");
Lejian lejian=new Lejian(request);
// wechat调用入口,进行数据接收,事件分发
String result=lejian.execute();
response.getOutputStream().write(result.getBytes());
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
Lejian lejian=new Lejian(request);
// wechat调用入口,进行数据接收,事件分发
String result=lejian.execute();
response.getOutputStream().write(result.getBytes());
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。