本文要点:
1、在公众号开发模式下,用代码设置公众后关注自动回复图文
2、单击图文跳转自定义链接
前提注意:
1、使用javen开发公众号
https://gitee.com/javen205/weixin_guide
2、拥有一个测试号
https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
在javen项目中,默认关注后是自动回复文本消息,以下修改为自动回复图文消息
在 com\javen\weixin\controller\WeixinMsgController.java中
/**
* 实现父类抽方法,处理关注/取消关注消息
*/
protected void processInFollowEvent(InFollowEvent inFollowEvent)
{
if (InFollowEvent.EVENT_INFOLLOW_SUBSCRIBE.equals(inFollowEvent.getEvent()))
{
logger.debug("关注:" + inFollowEvent.getFromUserName());
//OutTextMsg outMsg = new OutTextMsg(inFollowEvent);
OutNewsMsg outNews = new OutNewsMsg(inFollowEvent);
News news = new News();
news.setTitle("欢迎关注这个测试的公众号");
news.setDescription("这是一些不可描述");
news.setPicUrl("");//自定义
news.setUrl("");//自定义
outNews.addNews(news);
outNews.toXml();
render(outNews);
}
// 如果为取消关注事件,将无法接收到传回的信息
if (InFollowEvent.EVENT_INFOLLOW_UNSUBSCRIBE.equals(inFollowEvent.getEvent()))
{
logger.debug("取消关注:" + inFollowEvent.getFromUserName());
}
}