Open tianzhidao28 opened 7 years ago
请问二维码图片有生成吗?
应该是 第一次时 报文件路径不存在。。。 我上面的代码fix了这个
为什么不用okhttp 方便多了
package com.rocyuan.wechat.bean.msg;
import com.alibaba.fastjson.annotation.JSONField; import com.rocyuan.wechat.bean.msg.base.Sex; import com.rocyuan.wechat.bean.msg.base.WeChatMsg;
/**
Created by rocyuan on 2017/5/13. */ public class WeChatNameCardMsg extends WeChatMsg {
@JSONField(name = "RecommendInfo") private RecommendInfo recommendInfo;
public WeChatNameCardMsg() {
}
public String getRecommendUserName() { return recommendInfo.userName; }
public String getRecommendNickName() { return recommendInfo.nickName; }
public static class RecommendInfo {
@JSONField(name = "NickName")
private String nickName; /*袁祖***/
@JSONField(name = "UserName")
private String userName; /*@30c588817a13cad0518a209303986a4a*/
@JSONField(name = "Province")
private String province; /*湖北*/
@JSONField(name = "City")
private String city; /*中国*/
@JSONField(name = "Signature")
private String signature; /**/
@JSONField(name = "Sex")
private Sex sex; /*1*/
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public Sex getSex() {
return sex;
}
public void setSex(Sex sex) {
this.sex = sex;
}
}
public RecommendInfo getRecommendInfo() { return recommendInfo; }
public void setRecommendInfo(RecommendInfo recommendInfo) { this.recommendInfo = recommendInfo; } }
用这种方式 代码会不会好看一些。。
/**
Created by rocyuan on 2017/5/11. */ public enum MsgType { TEXT("Text",1), NameCard("NameCard",42), PIC("Pic",3), VIDEO("VIDEO",43), VOICE("Voice",34), Map("Map",1,48), Money_Transfer("Money_Transfer",49,0,2000), // 微信转账
SYSTEM("System",10000), SHARE_LINK("Share_Link",49,0,5), SHARE_FILE("Share_File",49,0,6), SHARE_DISCOUNT("Share_Discount",49,0,16), // 折扣 SHARE_APP("Share_App",49,0,33) // 小程序
;
MsgType(String type, int msgType,int subMsgType,int appMsgType) { this.type = type; this.msgType = msgType; this.subMsgType = subMsgType; this.appMsgType = appMsgType; }
MsgType(String type, int msgType,int subMsgType) { this.type = type; this.msgType = msgType; this.subMsgType = subMsgType; this.appMsgType = 0; }
MsgType(String type, int msgType) { this.type = type; this.msgType = msgType; this.subMsgType = 0; this.appMsgType = 0; }
private static final Map<String, MsgType> CODE_MAP = new HashMap<String, MsgType>();
static { for (MsgType typeEnum : MsgType.values()) { CODEMAP.put(typeEnum.msgType+""+typeEnum.subMsgType+"_"+typeEnum.appMsgType, typeEnum); } }
我看了一些 消息记录 发现 用int msgType,int subMsgType,int appMsgType 用这3个属性基本可以定位一个 类型了。
哇,收到,朋友,多谢,后面我会按照这种格式调整一下,再次感谢!!
https://github.com/tianzhidao28/wechat-service
可以参考下 我里面的。 包装了下你的
收到,非常感谢!
qrPath = qrPath + File.separator + "QR.jpg"; String qrUrl = baseUrl + "/qrcode/" + core.getUuid(); try { URL qrUrlPicture = new URL(qrUrl); File qrFile = new File(qrPath); FileUtils.copyURLToFile(qrUrlPicture, qrFile); CommonTool.printQr(qrPath); // 打开登陆二维码图片 } catch (MalformedURLException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; }