update md

This commit is contained in:
jinyu 2015-08-09 11:03:07 +08:00
parent 292fc5e01e
commit 55246ab9b4
6 changed files with 33 additions and 24 deletions

View File

@ -137,3 +137,7 @@
+ 新增了群发消息中的上传视频接口 + 新增了群发消息中的上传视频接口
+ 调整群发消息接口返回类型为字符串数组[{msg_id,msg_data_id}] + 调整群发消息接口返回类型为字符串数组[{msg_id,msg_data_id}]
* 2015-08-09
+ version upgrade to 1.5.2

View File

@ -93,3 +93,5 @@
+ 会话API暴露到WeixinProxy类 + 会话API暴露到WeixinProxy类
+ 重命名NotifyApi#sendNotify为sendNotifyMessage + 重命名NotifyApi#sendNotify为sendNotifyMessage
+ version upgrade to 1.5.2

View File

@ -77,3 +77,9 @@
* 2015-08-06 * 2015-08-06
+ 调整`LocationEventMessage`类中的经纬度字段类型为double + 调整`LocationEventMessage`类中的经纬度字段类型为double
* 2015-08-09
+ version upgrade to 1.0.4
+ 调整WeixinServerBootstrap明文构造函数的参数为token

View File

@ -39,7 +39,6 @@ public class WeixinResponseEncoder extends
List<Object> out) throws WeixinException { List<Object> out) throws WeixinException {
WeixinMessageTransfer messageTransfer = ctx.channel() WeixinMessageTransfer messageTransfer = ctx.channel()
.attr(Consts.MESSAGE_TRANSFER_KEY).get(); .attr(Consts.MESSAGE_TRANSFER_KEY).get();
AesToken aesToken = messageTransfer.getAesToken();
EncryptType encryptType = messageTransfer.getEncryptType(); EncryptType encryptType = messageTransfer.getEncryptType();
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
content.append("<xml>"); content.append("<xml>");
@ -55,6 +54,7 @@ public class WeixinResponseEncoder extends
content.append(response.toContent()); content.append(response.toContent());
content.append("</xml>"); content.append("</xml>");
if (encryptType == EncryptType.AES) { if (encryptType == EncryptType.AES) {
AesToken aesToken = messageTransfer.getAesToken();
String nonce = RandomUtil.generateString(32); String nonce = RandomUtil.generateString(32);
String timestamp = Long String timestamp = Long
.toString(System.currentTimeMillis() / 1000l); .toString(System.currentTimeMillis() / 1000l);

View File

@ -81,25 +81,23 @@ public final class WeixinServerBootstrap {
* *
* 明文模式 * 明文模式
* *
* @param weixinid
* 微信号(原始ID/appid/corpid)
* @param token * @param token
* 开发者token * 开发者token
* *
*/ */
public WeixinServerBootstrap(String weixinid, String token) { public WeixinServerBootstrap(String token) {
this(weixinid, token, null); this(null, token, null);
} }
/** /**
* 兼容模式 & 密文模式 * 明文模式 & 兼容模式 & 密文模式
* *
* @param appid * @param appid
* 公众号的应用ID(appid/corpid) * 公众号的应用ID(appid/corpid) 密文&兼容模式下需要填写
* @param token * @param token
* 开发者填写的token * 开发者填写的token 无论哪种模式都需要填写
* @param aesKey * @param aesKey
* 消息加密的密钥 * 消息加密的密钥 密文&兼容模式下需要填写
*/ */
public WeixinServerBootstrap(String appid, String token, String aesKey) { public WeixinServerBootstrap(String appid, String token, String aesKey) {
this(new AesToken(appid, token, aesKey)); this(new AesToken(appid, token, aesKey));
@ -142,12 +140,13 @@ public final class WeixinServerBootstrap {
throw new IllegalArgumentException("AesToken not be null"); throw new IllegalArgumentException("AesToken not be null");
} }
this.aesTokenMap = new HashMap<String, AesToken>(); this.aesTokenMap = new HashMap<String, AesToken>();
for (AesToken aesToken : aesTokens) {
this.aesTokenMap.put(aesToken.getWeixinId(), aesToken);
}
// default..
if (aesTokens.length == 1) { if (aesTokens.length == 1) {
this.aesTokenMap.put(aesTokens[0].getWeixinId(), aesTokens[0]);
this.aesTokenMap.put(null, aesTokens[0]); this.aesTokenMap.put(null, aesTokens[0]);
} else {
for (AesToken aesToken : aesTokens) {
this.aesTokenMap.put(aesToken.getWeixinId(), aesToken);
}
} }
this.messageHandlerList = new LinkedList<WeixinMessageHandler>(); this.messageHandlerList = new LinkedList<WeixinMessageHandler>();
this.messageInterceptorList = new LinkedList<WeixinMessageInterceptor>(); this.messageInterceptorList = new LinkedList<WeixinMessageInterceptor>();

View File

@ -24,9 +24,7 @@ import com.foxinmy.weixin4j.startup.WeixinServerBootstrap;
*/ */
public class MessageServerStartup { public class MessageServerStartup {
// 微信号(原始ID) // 公众号ID
final String openid = "gh_22b350df957b";
// 应用ID
final String appid = "wx4ab8f8de58159a57"; final String appid = "wx4ab8f8de58159a57";
// 开发者token // 开发者token
final String token = "weixin4j"; final String token = "weixin4j";
@ -40,8 +38,8 @@ public class MessageServerStartup {
*/ */
public void test1() throws WeixinException { public void test1() throws WeixinException {
// 所有请求都回复调试的文本消息 // 所有请求都回复调试的文本消息
new WeixinServerBootstrap(openid, token).addHandler( new WeixinServerBootstrap(token).addHandler(DebugMessageHandler.global)
DebugMessageHandler.global).startup(); .startup();
} }
/** /**
@ -77,8 +75,8 @@ public class MessageServerStartup {
public void test4() throws WeixinException { public void test4() throws WeixinException {
// 扫描包加载消息处理器 // 扫描包加载消息处理器
String packageToScan = "com.foxinmy.weixin4j.handler"; String packageToScan = "com.foxinmy.weixin4j.handler";
new WeixinServerBootstrap(openid, token).handlerPackagesToScan( new WeixinServerBootstrap(token).handlerPackagesToScan(packageToScan)
packageToScan).startup(); .startup();
} }
public void test5() throws WeixinException { public void test5() throws WeixinException {
@ -108,7 +106,7 @@ public class MessageServerStartup {
System.err.println("请求处理完毕"); System.err.println("请求处理完毕");
} }
}; };
new WeixinServerBootstrap(openid, token).addInterceptor(interceptor) new WeixinServerBootstrap(token).addInterceptor(interceptor)
.openAlwaysResponse().startup(); .openAlwaysResponse().startup();
} }