NutzCN Logo
问答 nutzWK集成微信
发布于 2556天前 作者 1037424761 1957 次浏览 复制 上一个帖子 下一个帖子
标签:
@IocBean
@At("/open/weixin")
public class WeixinController {
    private static final Log log = Logs.get();
    @Inject
    WxConfigService wxConfigService;
    @Inject
    WxHandler wxHandler;
    /*protected BasicWxHandler wxHandler = new BasicWxHandler("1234567890");*/

    public WeixinController() {
        Wxs.enableDevMode(); // 开启debug模式,这样就会把接收和发送的内容统统打印,方便查看
    }

    @At({"/api", "/api/?"})
    @Fail("http:200")
    public View msgIn(String key, HttpServletRequest req) throws IOException {
        return Wxs.handle(wxHandler, req, key);
    }

}

昨天试了用nutz做微信后台,
内网穿透 http://1037424761.ngrok.wendal.cn/appService/open/weixin/api
到了@At({"/api", "/api/?"})方法体里面 String key怎么获得?

4 回复

可以不写的, 只是为了区分不同的公众号

public boolean check(String signature, String timestamp, String nonce, String key) {
        Wx_config appInfo = wxConfigService.fetch(Cnd.where("id", "=", key));
        if(appInfo!=null){
            this.token=appInfo.getToken();
            this.aeskey=appInfo.getEncodingAESKey();
            this.appid=appInfo.getAppid();
            return Wxs.check(appInfo.getToken(), signature, timestamp, nonce);
        }
        return false;
    }

那WxHandler的token没有值啊,还是在一开始protected String token;就写个固定值

 /*Wx_config appInfo = wxConfigService.fetch(Cnd.where("id", "=", key));
        if(appInfo!=null){
            this.token=appInfo.getToken();
            this.aeskey=appInfo.getEncodingAESKey();
            this.appid=appInfo.getAppid();
            return Wxs.check(appInfo.getToken(), signature, timestamp, nonce);
        }
        return false;*/
    	this.token="1234567890";
        /*this.aeskey=appInfo.getEncodingAESKey();
        this.appid=appInfo.getAppid();*/
        return Wxs.check(token, signature, timestamp, nonce);

是这样吗?

那是界面上配的

添加回复
请先登陆
回到顶部