【特大注意】weixin4j.properties全部的属性名添加weixin4j前缀,并用.代替原来的_
This commit is contained in:
parent
ef5fb006f0
commit
19a350d6ed
@ -540,3 +540,5 @@
|
||||
+ 添加可选[RedisTokenStorager](weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/RedisTokenStorager.java)
|
||||
|
||||
+ 添加缓存token时的前缀`wx`
|
||||
|
||||
+ 【特大注意】weixin4j.properties全部的属性名添加`weixin4j`前缀,并用`.`代替原来的`_`
|
||||
|
||||
@ -26,14 +26,14 @@ weixin4j
|
||||
如何获取
|
||||
----------
|
||||
###1.maven依赖
|
||||
微信公众平台API(1.6.4,2015-12-08 released)
|
||||
微信公众平台API(1.6.4,2015-12-10 released)
|
||||
|
||||
<dependency>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
微信企业号API(1.6.4,2015-12-08 released)
|
||||
微信企业号API(1.6.4,2015-12-10 released)
|
||||
|
||||
<dependency>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
|
||||
@ -59,7 +59,7 @@ public abstract class BaseApi {
|
||||
static {
|
||||
DEFAULT_WEIXIN_ACCOUNT = Weixin4jConfigUtil.getWeixinAccount();
|
||||
DEFAULT_TOKEN_STORAGER = new FileTokenStorager(
|
||||
Weixin4jConfigUtil.getValue("token_path",
|
||||
Weixin4jConfigUtil.getValue("token.path",
|
||||
Weixin4jConst.DEFAULT_TOKEN_PATH));
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConst;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
@ -305,7 +306,8 @@ public class Pay3Api {
|
||||
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));
|
||||
|
||||
@ -115,7 +115,12 @@ public abstract class AbstractHttpClient implements HttpClient {
|
||||
protected void handleResponse(HttpResponse response)
|
||||
throws HttpClientException {
|
||||
HttpStatus status = response.getStatus();
|
||||
if (hasError(status)) {
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
String contentType = headers.getFirst(HttpHeaders.CONTENT_TYPE);
|
||||
boolean jsonResult = contentType != null
|
||||
&& contentType.contains(ContentType.APPLICATION_JSON
|
||||
.getMimeType());
|
||||
if (!jsonResult && hasError(status)) {
|
||||
switch (status.series()) {
|
||||
case CLIENT_ERROR:
|
||||
case SERVER_ERROR:
|
||||
|
||||
@ -28,7 +28,7 @@ public abstract class HttpClientFactory {
|
||||
private static volatile HttpClientFactory defaultFactory = newDefaultFactory();
|
||||
|
||||
/**
|
||||
* NettyHttpClient -> ApachHttpClient -> SimpleHttpClient(HttpURLConnection)
|
||||
* NettyHttpClient -> ApacheHttpClient -> SimpleHttpClient(HttpURLConnection)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -68,7 +68,7 @@ public class WeixinPayProxy {
|
||||
this.pay3Api = new Pay3Api(weixinAccount);
|
||||
this.couponApi = new CouponApi(weixinAccount);
|
||||
this.cashApi = new CashApi(weixinAccount);
|
||||
this.DEFAULT_CA_FILE = Weixin4jConfigUtil.getClassPathValue("ca_file",
|
||||
this.DEFAULT_CA_FILE = Weixin4jConfigUtil.getClassPathValue("certificate.file",
|
||||
Weixin4jConst.DEFAULT_CAFILE_PATH);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ package com.foxinmy.weixin4j.util;
|
||||
import java.io.File;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
@ -23,12 +22,11 @@ public class Weixin4jConfigUtil {
|
||||
private final static ResourceBundle weixinBundle;
|
||||
static {
|
||||
weixinBundle = ResourceBundle.getBundle("weixin4j");
|
||||
Set<String> keySet = weixinBundle.keySet();
|
||||
File file = null;
|
||||
CLASSPATH_VALUE = Thread.currentThread().getContextClassLoader()
|
||||
.getResource("").getPath();
|
||||
for (String key : keySet) {
|
||||
if (!key.endsWith("_path")) {
|
||||
for (String key : weixinBundle.keySet()) {
|
||||
if (!key.endsWith(".path")) {
|
||||
continue;
|
||||
}
|
||||
file = new File(getValue(key).replaceFirst(CLASSPATH_PREFIX,
|
||||
@ -40,6 +38,15 @@ public class Weixin4jConfigUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private final static String WEIXIN4J_PREFIX = "weixin4j";
|
||||
|
||||
private static String wrapKeyName(String key) {
|
||||
if (!key.startsWith(WEIXIN4J_PREFIX)) {
|
||||
return String.format("%s.%s", WEIXIN4J_PREFIX, key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取weixin4j.properties文件中的key值
|
||||
*
|
||||
@ -47,7 +54,8 @@ public class Weixin4jConfigUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getValue(String key) {
|
||||
return weixinBundle.getString(key);
|
||||
String wrapKey = wrapKeyName(key);
|
||||
return System.getProperty(wrapKey, weixinBundle.getString(wrapKey));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +68,7 @@ public class Weixin4jConfigUtil {
|
||||
public static String getValue(String key, String defaultValue) {
|
||||
String value = defaultValue;
|
||||
try {
|
||||
value = weixinBundle.getString(key);
|
||||
value = getValue(key);
|
||||
} catch (MissingResourceException e) {
|
||||
System.err.println("'" + key
|
||||
+ "' key not found in weixin4j.properties file.");
|
||||
@ -101,7 +109,8 @@ public class Weixin4jConfigUtil {
|
||||
public static WeixinAccount getWeixinAccount() {
|
||||
WeixinAccount account = null;
|
||||
try {
|
||||
account = JSON.parseObject(getValue("account"), WeixinAccount.class);
|
||||
account = JSON
|
||||
.parseObject(getValue("account"), WeixinAccount.class);
|
||||
} catch (MissingResourceException e) {
|
||||
System.err
|
||||
.println("'account' key not found in weixin4j.properties 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`前缀,并用`.`代替原来的`_`
|
||||
|
||||
@ -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")));
|
||||
}
|
||||
|
||||
|
||||
@ -132,6 +132,8 @@
|
||||
+【重要】第三方应用授权时获取永久授权码覆盖问题。
|
||||
|
||||
|
||||
* 2015-12-08
|
||||
* 2015-12-10
|
||||
|
||||
+ version upgrade to 1.6.4
|
||||
|
||||
+ 【特大注意】weixin4j.properties全部的属性名添加`weixin4j`前缀,并用`.`代替原来的`_`
|
||||
|
||||
@ -37,7 +37,7 @@ weixin4j-qy
|
||||
|
||||
如何使用
|
||||
--------
|
||||
0.maven依赖(1.6.4,2015-12-08 released)
|
||||
0.maven依赖(1.6.4,2015-12-10 released)
|
||||
|
||||
<dependency>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
@ -50,37 +50,37 @@ weixin4j.properties说明
|
||||
|
||||
| 属性名 | 说明 |
|
||||
| :---------- | :-------------- |
|
||||
| account | 微信企业号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) |
|
||||
| token_path | 使用FileTokenStorager时token保存的物理路径(非必须填写) |
|
||||
| media_path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) |
|
||||
| bill_path | 调用下载对账单接口保存文件的物理路径(非必须填写) |
|
||||
| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件(非必须填写) |
|
||||
| user_oauth_redirect_uri | 企业号用户身份授权后重定向的url(OauthApi接口) |
|
||||
| third_oauth_redirect_uri | 企业号第三方提供商授权后重定向的url(OauthApi接口) |
|
||||
| suite_oauth_redirect_uri | 企业号第三方应用套件授权后重定向的url(OauthApi接口) |
|
||||
| weixin4j.account | 微信企业号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) |
|
||||
| weixin4j.token.path | 使用FileTokenStorager时token保存的物理路径(非必须填写) |
|
||||
| weixin4j.media.path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) |
|
||||
| weixin4j.bill.path | 调用下载对账单接口保存文件的物理路径(非必须填写) |
|
||||
| weixin4j.certificate.file | 调用某些接口(支付相关)强制需要auth的ca授权文件(非必须填写) |
|
||||
| weixin4j.user.oauth.redirect.uri | 企业号用户身份授权后重定向的url(OauthApi接口) |
|
||||
| weixin4j.third.oauth.redirect.uri | 企业号第三方提供商授权后重定向的url(OauthApi接口) |
|
||||
| weixin4j.suite.oauth.redirect.uri | 企业号第三方应用套件授权后重定向的url(OauthApi接口) |
|
||||
|
||||
示例(properties中换行用右斜杆\\)
|
||||
|
||||
account={"id":"corpid","secret":"corpsecret",\
|
||||
weixin4j.account={"id":"corpid","secret":"corpsecret",\
|
||||
"suites":[{"id":"应用套件的id","secret":"应用套件的secret"}],\
|
||||
"providerSecret:"第三方提供商secret(企业号登陆)",\
|
||||
"chatSecret":"消息服务secret(企业号消息服务,暂时没用到)"}
|
||||
|
||||
token_path=/tmp/weixin4j/token
|
||||
media_path=/tmp/weixin4j/media
|
||||
bill_path=/tmp/weixin4j/bill
|
||||
weixin4j.token.path=/tmp/weixin4j/token
|
||||
weixin4j.media.path=/tmp/weixin4j/media
|
||||
weixin4j.bill.path=/tmp/weixin4j/bill
|
||||
# ca证书存放的完整路径 (证书文件后缀为*.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
|
||||
|
||||
#企业号用户身份授权后重定向的url(使用OauthApi时需要填写)
|
||||
user_oauth_redirect_uri=http://xxx
|
||||
weixin4j.user.oauth.redirect.uri=http://xxx
|
||||
|
||||
#企业号第三方管理员授权后重定向的url(使用OauthApi时需要填写)
|
||||
third_oauth_redirect_uri=http://xxx
|
||||
weixin4j.third.oauth.redirect.uri=http://xxx
|
||||
|
||||
#企业号第三方应用套件授权后重定向的url(使用OauthApi时需要填写)
|
||||
suite_oauth_redirect_uri=http://xxx
|
||||
weixin4j.suite.oauth.redirect.uri=http://xxx
|
||||
|
||||
2.实例化微信企业号接口代理对象,调用具体的API方法
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ public class MediaApi extends QyApi {
|
||||
*/
|
||||
public File downloadMediaFile(int agentid, String mediaId)
|
||||
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("%d_%s.", agentid, mediaId);
|
||||
File[] files = new File(media_path).listFiles(new FilenameFilter() {
|
||||
|
||||
@ -35,7 +35,7 @@ public class OauthApi extends QyApi {
|
||||
*/
|
||||
public String getUserAuthorizeURL() {
|
||||
String corpId = DEFAULT_WEIXIN_ACCOUNT.getId();
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("user_oauth_redirect_uri");
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("user.oauth.redirect.uri");
|
||||
return getUserAuthorizeURL(corpId, redirectUri, "state");
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class OauthApi extends QyApi {
|
||||
*/
|
||||
public String getThirdAuthorizeURL() {
|
||||
String corpId = DEFAULT_WEIXIN_ACCOUNT.getId();
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("third_oauth_redirect_uri");
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("third.oauth.redirect.uri");
|
||||
return getThirdAuthorizeURL(corpId, redirectUri, "state");
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public class OauthApi extends QyApi {
|
||||
* @return
|
||||
*/
|
||||
public String getSuiteAuthorizeURL(String suiteId, String preAuthCode) {
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("suite_oauth_redirect_uri");
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("suite.oauth.redirect.uri");
|
||||
return getSuiteAuthorizeURL(suiteId, preAuthCode, redirectUri, "state");
|
||||
}
|
||||
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
# \u6d4b\u8bd5\u4e4b\u7528 \u6b63\u5f0f\u73af\u5883\u4e0bcopy\u4e00\u4efd\u5230classpath
|
||||
# \u4f01\u4e1a\u53f7\u4fe1\u606f
|
||||
account={"id":"id","secret":"secret",\
|
||||
weixin4j.account={"id":"id","secret":"secret",\
|
||||
"suites":[{"id":"\u5e94\u7528\u5957\u4ef6\u7684id","secret":"\u5e94\u7528\u5957\u4ef6\u7684secret"}],\
|
||||
"providerSecret":"\u7b2c\u4e09\u65b9\u63d0\u4f9b\u5546secret(\u4f01\u4e1a\u53f7\u767b\u9646)",\
|
||||
"chatSecret":"\u6d88\u606f\u670d\u52a1secret(\u4f01\u4e1a\u53f7\u6d88\u606f\u670d\u52a1,\u6682\u65f6\u6ca1\u7528\u5230)"}
|
||||
|
||||
# \u4f7f\u7528FileTokenStorager\u65f6token\u7684\u5b58\u653e\u8def\u5f84
|
||||
token_path=/tmp/weixin4j/token
|
||||
weixin4j.token.path=/tmp/weixin4j/token
|
||||
# \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
|
||||
|
||||
# \u4f01\u4e1a\u53f7\u7528\u6237\u8eab\u4efd\u6388\u6743\u540e\u91cd\u5b9a\u5411\u7684url
|
||||
user_oauth_redirect_uri=
|
||||
weixin4j.user.oauth.redirect.uri=
|
||||
|
||||
# \u4f01\u4e1a\u53f7\u7b2c\u4e09\u65b9\u63d0\u4f9b\u5546\u6388\u6743\u540e\u91cd\u5b9a\u5411\u7684url
|
||||
third_oauth_redirect_uri=
|
||||
weixin4j.third.oauth.redirect.uri=
|
||||
|
||||
# \u4f01\u4e1a\u53f7\u7b2c\u4e09\u65b9\u5e94\u7528\u5957\u4ef6\u6388\u6743\u540e\u91cd\u5b9a\u5411\u7684url
|
||||
suite_oauth_redirect_uri=
|
||||
weixin4j.suite.oauth.redirect.uri=
|
||||
@ -48,7 +48,7 @@ public class MenuTest extends TokenTest {
|
||||
|
||||
@Test
|
||||
public void get() throws WeixinException {
|
||||
btnList = menuApi.getMenu(1);
|
||||
btnList = menuApi.getMenu(0);
|
||||
for (Button btn : btnList) {
|
||||
System.out.println(btn);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class TokenTest {
|
||||
tokenHolder = new TokenHolder(new WeixinTokenCreator(
|
||||
weixinAccount.getId(), weixinAccount.getSecret()),
|
||||
new FileTokenStorager(Weixin4jConfigUtil.getValue(
|
||||
"token_path", "/tmp/weixin4j/token")));
|
||||
"token.path", "/tmp/weixin4j/token")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user