代码里用到签名的地方
WxApi2 wxApi2 = wxConfigService.getWxApi2(wxUser.getWxid());
if (Lang.isEmpty(Globals.memoryJsapiTicketStore.get(wxUser.getWxid()))) {
Globals.memoryJsapiTicketStore.put(wxUser.getWxid(), new MemoryJsapiTicketStore());
}
MemoryJsapiTicketStore memoryJsapiTicketStore = Globals.memoryJsapiTicketStore.get(wxUser.getWxid());
wxApi2.setJsapiTicketStore(memoryJsapiTicketStore);
String url = "http://" + Globals.AppDomain + Globals.AppBase + "/public/wx/selfRecord/toUpload/" + UUID.randomUUID();
NutMap jsConfig = wxApi2.genJsSDKConfig(url, "chooseImage", "previewImage", "uploadImage", "downloadImage");
初始化的时候,设置了accesstoken
public synchronized WxApi2 getWxApi2(String wxid) {
WxApi2Impl wxApi2 = Globals.WxMap.get(wxid);
if (wxApi2 == null) {
Wx_config appInfo = this.fetch(Cnd.where("id", "=", wxid));
wxApi2 = new WxApi2Impl();
wxApi2.setAppid(appInfo.getAppid());
wxApi2.setAppsecret(appInfo.getAppsecret());
wxApi2.setEncodingAesKey(appInfo.getEncodingAESKey());
wxApi2.setToken(appInfo.getToken());
wxApi2.setAccessTokenStore(new MemoryAccessTokenStore());
Globals.WxMap.put(wxid, wxApi2);
}
return wxApi2;
}
用wxApi2里的 jsapi_ticket值 加上 jsConfig里的timestamp,noncestr,url 生成的signature不一致呢。
源码里 是不是有问题啊。 有个 %d 不是 %s吗
@Override
public NutMap genJsSDKConfig(String url, String... jsApiList) {
String jt = this.getJsapiTicket();
long timestamp = System.currentTimeMillis();
String nonceStr = R.UU64();
String str = String.format("jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s", jt, nonceStr, timestamp, url);