zoukankan      html  css  js  c++  java
  • java响应微信用户信息(wechat4j)

    你的微信应用程序接收到用户发送的消息事件之后,可以进行响应。wechat4j支持多种消息的响应。

    wechat4j响应消息的部分在wechat4j的入口WechatSupport.java中定义,直接使用即可。如下以接收文本消息然后回复给用户文本消息为例来说明。

    public class YouWechat extends WechatSupport{
    	public Lejian(HttpServletRequest request, String token) {
    		super(request, token);
    	}
    
    	@Override
    	protected void onText() {
    		this.wechatRequest.getFromUserName();
    		String content = "test ok";
    		responseText(content);
    	}
    }
    

    上面代码的意思就是创建一个你自己的微信服务YouWechat.java必须继承wechat4j的WechatSupport。实现其onText事件。通过String content = "test ok"来设置回复的消息,然后使用responseText(content)进行消息回复,其中responseText(content)就是响应文本消息方法。

    wechat4j响应消息列表

    • responseText 回复文本消息
    • responseImage 回复图片消息
    • responseVoice 回复语音消息
    • responseVideo 回复视频消息
    • responseMusic 回复音乐消息
    • responseNew 回复图文消息
    • responseNews 回复图文消息

    官方文档: https://github.com/sword-org/wechat4j/wiki

  • 相关阅读:
    numpy操作
    python将整数均分成N等分
    Windows7下安装pyspark
    python的append insert extend pop del remove使用
    马尔科夫链
    dataframe行变换为列
    scala获取某个时间间隔的时间
    Python3+Flask+uwsgi部署
    A*寻路算法
    C++易混淆知识点整理
  • 原文地址:https://www.cnblogs.com/chengn/p/4262592.html
Copyright © 2011-2022 走看看