已经迁移到 美团技术服务合作中心
**一、涉及对象
对接到店综合业务的所有开发者。
二、迁移时间
需在2024年9月13日前入驻美团技术服务合作中心,获取开发者身份,原到综业务平台将于2024年11月13日停止服务,请尽快完成能力迁移** 。
~~美团北极星 洗涤行业对接
美团洗衣行业对接 java代码
签名不一致 sign值不一致
中文乱码导致的 本地测试没问题 线上tomcat有问题
需要先去下载java SDK ~~
SDK 版本:
java代码
public static String generateSign(GenerateSignRequest generateSignRequest) {
if (generateSignRequest == null) {
throw new IllegalArgumentException("generateSign generateSignRequest is null");
} else {
Map<String, String> params = generateSignRequest.getParams();
AssertUtils.checkArgument(params != null && !params.isEmpty(), "generateSign apiRequest is null,generateSignRequest:" + generateSignRequest);
List<String> keys = new ArrayList();
Iterator var3 = params.entrySet().iterator();
while(var3.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry)var3.next();
if (org.apache.commons.lang.StringUtils.isNotEmpty((String)entry.getValue())) {
keys.add(entry.getKey());
}
}
Collections.sort(keys);
StringBuilder sb = new StringBuilder();
if (org.apache.commons.lang.StringUtils.isNotEmpty(generateSignRequest.getAppSecret())) {
sb.append(generateSignRequest.getAppSecret());
}
Iterator var8 = keys.iterator();
String sign;
while(var8.hasNext()) {
sign = (String)var8.next();
sb.append(sign).append(((String)params.get(sign)).trim());
}
if (org.apache.commons.lang.StringUtils.isNotEmpty(generateSignRequest.getAppSecret())) {
sb.append(generateSignRequest.getAppSecret());
}
String encryptionKey = sb.toString().trim();
if (generateSignRequest.getSignMethod().equals(SignMethodEnum.MD5.getType())) {
try {
sign =genMd5(encryptionKey);
return sign;
} catch (Exception var6) {
throw new RuntimeException(var6.getMessage());
}
} else {
return "";
}
}
}
public static String genMd5(String info) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] infoBytes = info.getBytes("UTF-8");
md5.update(infoBytes);
byte[] sign = md5.digest();
return byteArrayToHex(sign);
}
public static String byteArrayToHex(byte[] bytes) {
StringBuilder sign = new StringBuilder();
for(int i = 0; i < bytes.length; ++i) {
String hex = Integer.toHexString(bytes[i] & 255);
if (hex.length() == 1) {
sign.append("0");
}
sign.append(hex.toLowerCase());
}
return sign.toString();
}
表评论2009
你能验券吗,我接口都不通啊 报什么验证渠道不合法
直接调用官方sdk就可以