JFinal Weixin开发 获取菜单

andying 发布于 2016/04/04 20:14
阅读 891
收藏 0

@JFinal 你好,想跟你请教个问题:

我在IE中输入以下地址,获取菜单,报以下错误:

http://127.0.0.1:8080/api/getMenu

警告: retry on 1 times v = null
java.lang.RuntimeException: java.lang.RuntimeException: jfinal 2.2默认 json 实现暂不支持 json 到 object 的转换,建议使用 active recrord 的 Generator 生成 base model,再通过 me.setJsonFactory(new JacksonFactory()) 来支持
at com.jfinal.weixin.sdk.api.AccessToken.<init>(AccessToken.java:45)
at com.jfinal.weixin.sdk.api.AccessTokenApi$1.call(AccessTokenApi.java:72)
at com.jfinal.weixin.sdk.api.AccessTokenApi$1.call(AccessTokenApi.java:67)
at com.jfinal.weixin.sdk.utils.RetryUtils.retryOnException(RetryUtils.java:34)
at com.jfinal.weixin.sdk.api.AccessTokenApi.refreshAccessToken(AccessTokenApi.java:67)
at com.jfinal.weixin.sdk.api.AccessTokenApi.getAccessToken(AccessTokenApi.java:45)
at com.jfinal.weixin.sdk.api.AccessTokenApi.getAccessTokenStr(AccessTokenApi.java:54)
at com.jfinal.weixin.sdk.api.MenuApi.getMenu(MenuApi.java:23)
at com.weixin.demo.ApiController.getMenu(ApiController.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:74)
at com.demo.common.MyContextPathHandler.handle(MyContextPathHandler.java:37)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1774)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: jfinal 2.2默认 json 实现暂不支持 json 到 object 的转换,建议使用 active recrord 的 Generator 生成 base model,再通过 me.setJsonFactory(new JacksonFactory()) 来支持
at com.jfinal.json.JFinalJson.parse(JFinalJson.java:335)
at com.jfinal.weixin.sdk.utils.JsonUtils.parse(JsonUtils.java:148)
at com.jfinal.weixin.sdk.api.AccessToken.<init>(AccessToken.java:35)
... 28 more
2016-4-4 19:53:53 com.jfinal.core.ActionHandler error
严重: /api/getMenu




加载中
1
andying
andying
问题已解决,原来template_id是公众号分配的,填写上你的公众号上模板Id即可,谢谢大家。
1
如梦技术
如梦技术
看jfinal-weiki 加上fastjson或者jackson jar包即可,不需要额外配置
如梦技术
如梦技术
jfinal-weixin Wiki
0
JFinal
JFinal
   是否使用的最新版本 jfinal weixin 1.7 ?
0
andying
andying

引用来自“JFinal”的评论

   是否使用的最新版本 jfinal weixin 1.7 ?

是用的最新的Jar包呀

jfinal-weixin-1.7-bin-with-src.jar

0
andying
andying

引用来自“Dreamlu”的评论

看jfinal-weiki 加上fastjson或者jackson jar包即可,不需要额外配置

刚对比了一下Git上的demo,确实少了fastjson.jar包,加上去ok了,谢谢.

新问题来了,现在我想针对某一个用户发信息,如下:

public void sendMsg()
	{

		
		ApiConfigKit.setThreadLocalApiConfig(getApiConfig());
		
		String str = " {\n" +
				"           \"touser\":\"opopruxxxxxxxxx\",\n" +
				"           \"template_id\":\"9SIa8ph1403NEM3qk3z9-go-p4kBMeh-HGepQZVdA7w\",\n" +
				"           \"url\":\"http://www.sina.com\",\n" +
				"           \"topcolor\":\"#FF0000\",\n" +
				"           \"data\":{\n" +
				"                   \"first\": {\n" +
				"                       \"value\":\"恭喜你购买成功!\",\n" +
				"                       \"color\":\"#173177\"\n" +
				"                   },\n" +
				"                   \"keyword1\":{\n" +
				"                       \"value\":\"去哪儿网发的酒店红包(1个)\",\n" +
				"                       \"color\":\"#173177\"\n" +
				"                   },\n" +
				"                   \"keyword2\":{\n" +
				"                       \"value\":\"1元\",\n" +
				"                       \"color\":\"#173177\"\n" +
				"                   },\n" +
				"                   \"remark\":{\n" +
				"                       \"value\":\"欢迎再次购买!\",\n" +
				"                       \"color\":\"#173177\"\n" +
				"                   }\n" +
				"           }\n" +
				"       }";
		ApiResult apiResult = TemplateMsgApi.send(str);
		renderText(apiResult.getJson());
	}



返回以下信息:

{"errcode":40037,"errmsg":"invalid template_id hint: [GIMuiA0650age9]"}
 

返回顶部
顶部