Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

统一下单detail处理为"null"字符串,detail为空时,会造成签名签名错误 #73

Closed
mnshun opened this issue Apr 6, 2017 · 5 comments

Comments

@mnshun
Copy link

mnshun commented Apr 6, 2017

解决方案
weixin.popular.util.MapUtil
/**
* url 参数串连
* @param map map
* @param keyLower keyLower
* @param valueUrlencode valueUrlencode
* @return string
*/
public static String mapJoin(Map<String, String> map,boolean keyLower,boolean valueUrlencode){
StringBuilder stringBuilder = new StringBuilder();
for(String key :map.keySet()){
if(map.get(key)!=null&&!"".equals(map.get(key))&&!"null".equals(map.get(key))){
// if(map.get(key)!=null&&!"".equals(map.get(key))){
try {
String temp = (key.endsWith("_")&&key.length()>1)?key.substring(0,key.length()-1):key;
stringBuilder.append(keyLower?temp.toLowerCase():temp)
.append("=")
.append(valueUrlencode?URLEncoder.encode(map.get(key),"utf-8").replace("+", "%20"):map.get(key))
.append("&");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
if(stringBuilder.length()>0){
stringBuilder.deleteCharAt(stringBuilder.length()-1);
}
return stringBuilder.toString();
}

@liyiorg
Copy link
Owner

liyiorg commented Apr 7, 2017

已发布2.8.8 ,问题已修复

@jingdongWang92
Copy link

大神,签名错误怎么解决啊。 参数什么的都没有问题,但是一直报签名错误
image

@jingdongWang92
Copy link

image

@liyiorg
Copy link
Owner

liyiorg commented Apr 26, 2017

@jingdongWang92 你那边使用版本是最新的 2.8.8 吗

@liyiorg
Copy link
Owner

liyiorg commented Apr 26, 2017

你可以尝试将 weixin-popular 在pom.xml 文件的依赖位置放到最前面,以避免其自身依赖的jar 包版本号不对。

@liyiorg liyiorg closed this as completed Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants