- java 上传电子发票文件一直提示签名错误?无法排查求助各位大佬
求助各位大佬是否有对应的代码片段参考!!!!!!!!!! https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/fapiao-applications/upload-fapiao-file 接口地址 返回的参数{"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":119,"truncated_sign_message":"POST\n/v3/new-tax-control-fapiao/fapiao-applications/upload-fapiao-file\n1733365654080\n4df7b7ae369d4afe91710bfb62dca2cb\n\n","url":"/v3/new-tax-control-fapiao/fapiao-applications/upload-fapiao-file"}},"message":"错误的签名,验签失败"} String pdfUrl = "http://121.33.250.162:18001/saas-industry/ebill.html?t=%C3%BD_%C3%BD%C3%90%C3%A5%C4%9C%C3%9C%C3%B9%C3%83%C3%85%C4%ACtx%C3%9A"; Path path = CommonUtils.downloadFileFromUrl(pdfUrl); String filePath = path.toString(); String digest = CommonUtils.sm3(filePath); JSONObject meta = new JSONObject(); meta.put("file_type", "PDF"); meta.put("digest", digest); meta.put("digest_algorithm", "SM3"); String jsonString = meta.toJSONString(); HttpUrl parse = HttpUrl.parse(MiniProgramConstant.MINI_PROGRAM_UPLOAD_INVOICE_FILE_URL); String signatureString = WxSignatureUtil.getSignatureString("POST", parse, jsonString); log.info("signature[{}]", signatureString); MultipartBody multipartBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("meta", "meta", RequestBody.create(jsonString,MediaType.parse("application/json"))) .addFormDataPart("file", "file", RequestBody.create(new File(filePath), MediaType.parse("pdf/plain"))) .build(); Request build = new Request.Builder() .addHeader("Authorization", signatureString) .addHeader("Accept", "application/json") .url(MiniProgramConstant.MINI_PROGRAM_UPLOAD_INVOICE_FILE_URL) .post(multipartBody) .build(); OkHttpClient client = new OkHttpClient(); Response response = client.newCall(build).execute(); ResponseBody responseBody = response.body(); 签名代码 public static String getSignatureString(String method, HttpUrl url, String body) throws Exception { String nonceStr = WxPayKit.generateStr(); long timestamp = System.currentTimeMillis(); String message = buildMessage(method, url, timestamp, nonceStr, body); String signature = sign(message.getBytes("utf-8")); return "WECHATPAY2-SHA256-RSA2048 mchid=\"" + mchid + "\"," + "nonce_str=\"" + nonceStr + "\"," + "timestamp=\"" + timestamp + "\"," + "serial_no=\"" + serial + "\"," + "signature=\"" + signature + "\""; } public static String sign(byte[] message) throws Exception { Signature sign = Signature.getInstance("SHA256withRSA"); sign.initSign(getPrivateKeyFromUrl("pem.url")); sign.update(message); return Base64.getEncoder().encodeToString(sign.sign()); } public static String buildMessage(String method, HttpUrl url, long timestamp, String nonceStr, String body) { String canonicalUrl = url.encodedPath(); if (url.encodedQuery() != null) { canonicalUrl += "?" + url.encodedQuery(); } return method + "\n" + canonicalUrl + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"; }
2024-12-05 - 同一个模板消息,昨天可以今天不行?47001, errmsg=data format erro
{"data":{"name3":{"value":"刘啦啦"},"thing7":{"value":"哥哥哥哥哥哥哥哥哥哥哥哈哈"},"date5":{"value":"2022-11-07 18:29:04"},"phrase6":{"value":"心理咨询"},"name1":{"value":"吴彦祖"}},"lang":"zh_CN","miniprogram_state":"trial","page":"pages/index/index","template_id":"template_id","touser":"touser"} 这个是成功参数, {"data":{"name3":{"value":"回测医"},"thing7":{"value":"11111111111111111111..."},"date5":{"value":"2022-11-08 13:33:44"},"phrase6":{"value":"快速问诊"},"name1":{"value":"很不很不开心"}},"lang":"zh_CN","miniprogram_state":"trial","page":"pages/index/index","template_id":"template_id","touser":"touser"} 这个是错误参数 47001, errmsg=data format erro 麻烦各位大佬解答一下
2022-11-08 - oauth2/access_token和/cgi-bin/token这两个获取的token冲突吗?
微信官方文档 这个接口获取的token去调用https://api.weixin.qq.com/sns/userinfo获取用户的unionId https://api.weixin.qq.com/sns/oauth2/access_token 这个接口获取到的token,根据旧openId去调用https://api.weixin.qq.com/cgi-bin/user/info获取unionId https://api.weixin.qq.com/cgi-bin/token 这两个接口获取的token是否冲突,还是获取一个token两个接口就能公用
2021-11-25 - 微信统一下单,大部分订单成功,个别订单下单签名出错,支付成功但是结果签名出错?
大部分订单都没有问题 appid和商户号,apikey都对过没有问题 签名生成代码: 随机字符串生成 [图片] Utf-8编码,MD5签名 [图片] [图片] [图片] 异常: [图片]
2021-11-18 - 公众号通过官方文档的api为旧用户使用openId获取unionId,有些能获取的到有些获取不到?
麻烦微信客服抽空回答一下,请求帮助 官方API:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN 微信公众号:旧用户使用Openid,去获取unionId但是有些用户能获取的到unionId 有些用户获取不到unionId,请问是什么问题,欢迎各路吴彦祖帮忙解答 需要实现公众号与小程序之间的数据公用, [图片] [图片]
2021-11-11 - java微信退款出现IO:keystore password was incorre
支付没有问题,之前退款是没有问题的,然后突然不能用,证书重新生成过,双击下载过
2021-11-02 - 以前小程序用户都没unionid,有没有官方的接口用openID获取unionID与公众号关联数据
https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html
2021-10-11