【特大注意】weixin4j.properties全部的属性名添加weixin4j前缀,并用.代替原来的_

This commit is contained in:
jinyu
2015-12-10 17:54:21 +08:00
parent ef5fb006f0
commit 19a350d6ed
24 changed files with 105 additions and 81 deletions
+3 -1
View File
@@ -170,6 +170,8 @@
+ version upgrade to 1.6.3
* 2015-12-08
* 2015-12-10
+ version upgrade to 1.6.4
+ 【特大注意】weixin4j.properties全部的属性名添加`weixin4j`前缀,并用`.`代替原来的`_`
+16 -16
View File
@@ -43,7 +43,7 @@ weixin4j-mp
如何使用
--------
0.maven依赖(1.6.4,2015-12-08 released)
0.maven依赖(1.6.4,2015-12-10 released)
<dependency>
<groupId>com.foxinmy</groupId>
@@ -56,32 +56,32 @@ weixin4j.properties说明
| 属性名 | 说明 |
| :---------- | :-------------- |
| account | 微信公众号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) |
| token_path | 使用FileTokenStorager时token保存的物理路径(非必须填写) |
| qr_path | 调用二维码接口时保存二维码图片的物理路径(非必须填写) |
| media_path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) |
| bill_path | 调用下载对账单接口保存文件的物理路径(非必须填写) |
| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件(按须填写) |
| user_oauth_redirect_uri | 调用OauthApi接口时需要填写的重定向路径(非必须填写) |
| weixin4j.account | 微信公众号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) |
| weixin4j.token.path | 使用FileTokenStorager时token保存的物理路径(非必须填写) |
| weixin4j.qrcode.path | 调用二维码接口时保存二维码图片的物理路径(非必须填写) |
| weixin4j.media.path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) |
| weixin4j.bill.path | 调用下载对账单接口保存文件的物理路径(非必须填写) |
| weixin4j.certificate.file | 调用某些接口(支付相关)强制需要auth的ca授权文件(按须填写) |
| weixin4j.user.oauth.redirect.uri | 调用OauthApi接口时需要填写的重定向路径(非必须填写) |
完整填写示例(properties中换行用右斜杆\\)
account={"id":"appId","secret":"appSecret",\
weixin4j.account={"id":"appId","secret":"appSecret",\
"mchId":"V3.x版本下的微信商户号",\
"partnerId":"V2版本下的财付通的商户号",\
"partnerKey":"V2版本下的财付通商户权限密钥Key",\
"paySignKey":"微信支付中调用API的密钥"}
token_path=/tmp/weixin4j/token
qr_path=/tmp/weixin4j/qrcode
media_path=/tmp/weixin4j/media
bill_path=/tmp/weixin4j/bill
weixin4j.token.path=/tmp/weixin4j/token
weixin4j.qrcode.path=/tmp/weixin4j/qrcode
weixin4j.media.path=/tmp/weixin4j/media
weixin4j.bill.path=/tmp/weixin4j/bill
# ca证书存放的完整路径 (V2版本后缀为*.pfx,V3版本后缀为*.p12)
ca_file=/tmp/weixin4j/xxxxx.p12
#classpath路径下:ca_file=classpath:xxxxx.p12
weixin4j.certificate.file=/tmp/weixin4j/xxxxx.p12
#classpath路径下:weixin4j.certificate.file=classpath:xxxxx.p12
#公众号登陆授权的重定向路径(使用OauthApi时需要填写)
user_oauth_redirect_uri=http://xxx
weixin4j.user.oauth.redirect.uri=http://xxx
2.实例化微信企业号接口代理对象,调用具体的API方法
@@ -249,7 +249,7 @@ public class MediaApi extends MpApi {
*/
public File downloadMediaFile(String mediaId, boolean isMaterial)
throws WeixinException {
String media_path = Weixin4jConfigUtil.getValue("media_path",
String media_path = Weixin4jConfigUtil.getValue("media.path",
Weixin4jConst.DEFAULT_MEDIA_PATH);
final String prefixName = String.format("%s.", mediaId);
File[] files = new File(media_path).listFiles(new FilenameFilter() {
@@ -33,7 +33,7 @@ public class OauthApi extends MpApi {
public String getAuthorizeURL() {
String appId = DEFAULT_WEIXIN_ACCOUNT.getId();
String redirectUri = Weixin4jConfigUtil
.getValue("user_oauth_redirect_uri");
.getValue("user.oauth.redirect.uri");
return getAuthorizeURL(appId, redirectUri, "state", "snsapi_base");
}
@@ -51,6 +51,7 @@ import com.foxinmy.weixin4j.util.DigestUtil;
import com.foxinmy.weixin4j.util.MapUtil;
import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
import com.foxinmy.weixin4j.util.Weixin4jConst;
import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer;
/**
@@ -346,7 +347,7 @@ public class Pay2Api extends MpApi {
* @since V2
* @throws WeixinException
*/
public File downloadbill(Date billDate, BillType billType)
public File downloadBill(Date billDate, BillType billType)
throws WeixinException {
if (billDate == null) {
Calendar now = Calendar.getInstance();
@@ -357,7 +358,8 @@ public class Pay2Api extends MpApi {
billType = BillType.ALL;
}
String formatBillDate = DateUtil.fortmat2yyyyMMdd(billDate);
String bill_path = Weixin4jConfigUtil.getValue("bill_path");
String bill_path = Weixin4jConfigUtil.getValue("bill.path",
Weixin4jConst.DEFAULT_BILL_PATH);
String fileName = String.format("%s_%s_%s.txt", formatBillDate,
billType.name().toLowerCase(), weixinAccount.getId());
File file = new File(String.format("%s/%s", bill_path, fileName));
@@ -80,7 +80,7 @@ public class QrApi extends MpApi {
* @see com.foxinmy.weixin4j.mp.model.QRParameter
*/
public File createQRFile(QRParameter parameter) throws WeixinException {
String qr_path = Weixin4jConfigUtil.getValue("qr_path",
String qr_path = Weixin4jConfigUtil.getValue("qrcode.path",
Weixin4jConst.DEFAULT_QRCODE_PATH);
String filename = String.format("%s_%s_%d.jpg", parameter.getQrType()
.name(), parameter.getSceneValue(), parameter
@@ -1,23 +1,23 @@
# \u6d4b\u8bd5\u4e4b\u7528 \u6b63\u5f0f\u73af\u5883\u4e0bcopy\u4e00\u4efd\u5230classpath
# \u516c\u4f17\u53f7\u4fe1\u606f
account={"id":"wx4ab8f8de58159a57","secret":"1d4eb0f4bf556aaed539f30ed05ca795",\
weixin4j.account={"id":"wx4ab8f8de58159a57","secret":"1d4eb0f4bf556aaed539f30ed05ca795",\
"mchId":"V3.x\u7248\u672c\u4e0b\u7684\u5fae\u4fe1\u5546\u6237\u53f7 \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165",\
"partnerId":"V2\u7248\u672c\u4e0b\u7684\u8d22\u4ed8\u901a\u7684\u5546\u6237\u53f7 \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165",\
"partnerKey":"V2\u7248\u672c\u4e0b\u7684\u8d22\u4ed8\u901a\u5546\u6237\u6743\u9650\u5bc6\u94a5Key \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165",\
"paySignKey":"\u5fae\u4fe1\u652f\u4ed8\u4e2d\u8c03\u7528API\u7684\u5bc6\u94a5 \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165"}
# \u4f7f\u7528FileTokenStorager\u65f6token\u7684\u5b58\u653e\u8def\u5f84
token_path=/tmp/weixin4j/token
weixin4j.token.path=/tmp/weixin4j/token
# \u4e8c\u7ef4\u7801\u4fdd\u5b58\u8def\u5f84
qr_path=/tmp/weixin4j/qrcode
weixin4j.qrcode.path=/tmp/weixin4j/qrcode
# \u5a92\u4f53\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84
media_path=/tmp/weixin4j/media
weixin4j.media.path=/tmp/weixin4j/media
# \u5bf9\u8d26\u5355\u4fdd\u5b58\u8def\u5f84
bill_path=/tmp/weixin4j/bill
weixin4j.bill.path=/tmp/weixin4j/bill
# ca\u8bc1\u4e66\u5b58\u653e\u7684\u5b8c\u6574\u8def\u5f84 (V2\u7248\u672c\u540e\u7f00\u4e3a*.pfx,V3\u7248\u672c\u540e\u7f00\u4e3a*.p12)
ca_file=/tmp/weixin4j/xxxxx.p12
weixin4j.certificate.file=/tmp/weixin4j/xxxxx.p12
# classpath\u8def\u5f84\u4e0b\u53ef\u4ee5\u8fd9\u4e48\u5199
# ca_file=classpath:xxxxx.pfx
# weixin4j.certificate.file=classpath:xxxxx.pfx
# \u7528\u6237oauth\u6388\u6743\u540e\u91cd\u5b9a\u5411\u7684url
user_oauth_redirect_uri=
weixin4j.user.oauth.redirect.uri=
@@ -37,7 +37,7 @@ public class PayTest {
"请填入v2版本的partnerKey");
PAY2 = new Pay2Api(ACCOUNT2, new FileTokenStorager(
Weixin4jConfigUtil
.getValue("token_path", "/tmp/weixin4j/token")));
.getValue("token.path", "/tmp/weixin4j/token")));
ACCOUNT3 = new WeixinPayAccount("请填入v3版本的appid", "请填入v3版本的appSecret",
"请填入v3版本的paysignkey", "请填入v3版本的mchid", null, null, null, null);
PAY3 = new WeixinPayProxy(ACCOUNT3);
@@ -74,7 +74,7 @@ public class PayTest {
c.set(Calendar.YEAR, 2014);
c.set(Calendar.MONTH, 11);
c.set(Calendar.DAY_OF_MONTH, 22);
File file = PAY2.downloadbill(c.getTime(), null);
File file = PAY2.downloadBill(c.getTime(), null);
System.err.println(file);
}
@@ -28,7 +28,7 @@ public class TokenTest {
WeixinAccount weixinAccount = Weixin4jConfigUtil.getWeixinAccount();
tokenHolder = new TokenHolder(new WeixinTokenCreator(
weixinAccount.getId(), weixinAccount.getSecret()),
new FileTokenStorager(Weixin4jConfigUtil.getValue("token_path",
new FileTokenStorager(Weixin4jConfigUtil.getValue("token.path",
"/tmp/weixin4j/token")));
}