|
@@ -18,7 +18,8 @@ public class WxUtil {
|
|
|
* @description app端通过用户授权码获取用户openId
|
|
|
*/
|
|
|
public static String getAppOpenIdByAuthCode(String authCode) {
|
|
|
- return getOpenIdByAuthCode(authCode, WxConstants.AppConfigConstants.APP_ID,
|
|
|
+ return getOpenIdByAuthCode(authCode, WxConstants.AppConfigConstants.OPEN_ID_URL,
|
|
|
+ WxConstants.AppConfigConstants.APP_ID,
|
|
|
WxConstants.AppConfigConstants.APP_SECRET);
|
|
|
}
|
|
|
|
|
@@ -29,7 +30,8 @@ public class WxUtil {
|
|
|
* @date 2020/4/27 10:36 上午
|
|
|
*/
|
|
|
public static String getAppletOpenIdByAuthCode(String authCode) {
|
|
|
- return getOpenIdByAuthCode(authCode, WxConstants.AppletConfigConstants.APP_ID,
|
|
|
+ return getOpenIdByAuthCode(authCode, WxConstants.AppletConfigConstants.OPEN_ID_URL,
|
|
|
+ WxConstants.AppletConfigConstants.APP_ID,
|
|
|
WxConstants.AppletConfigConstants.APP_SECRET);
|
|
|
}
|
|
|
|
|
@@ -41,9 +43,8 @@ public class WxUtil {
|
|
|
* @description 通过授权码获取微信openId
|
|
|
* @date 2020/4/30 2:47 下午
|
|
|
*/
|
|
|
- private static String getOpenIdByAuthCode(String authCode, String appId, String appSecret) {
|
|
|
- String url = WxConstants.USER_INFO_ACCESS_TOKEN_URL
|
|
|
- .replace("APPID", appId)
|
|
|
+ private static String getOpenIdByAuthCode(String authCode, String url, String appId, String appSecret) {
|
|
|
+ url = url.replace("APPID", appId)
|
|
|
.replace("SECRET", appSecret)
|
|
|
.replace("CODE", authCode);
|
|
|
JSONObject result = JSONUtil.parseObj(HttpUtil.get(url));
|