|
|
|
@@ -3,8 +3,10 @@ package com.iformall.douyin.miniapp.api.impl; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|
|
|
import cn.binarywang.wx.miniapp.config.WxMaConfig; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.base.Joiner; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.JsonParser; |
|
|
|
import com.iformall.douyin.miniapp.api.*; |
|
|
|
import com.iformall.douyin.miniapp.api.bean.TtMaGsonBuilder; |
|
|
|
@@ -125,7 +127,9 @@ public class TtMaServiceImpl implements TtMaService, RequestHttp<CloseableHttpCl |
|
|
|
if (error.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(error); |
|
|
|
} |
|
|
|
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); |
|
|
|
JSONObject jsonObject = JSON.parseObject(resultContent); |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
WxAccessToken accessToken = WxAccessToken.fromJson(data.toJSONString()); |
|
|
|
this.getWxMaConfig().updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); |
|
|
|
|
|
|
|
return this.getWxMaConfig().getAccessToken(); |
|
|
|
@@ -151,9 +155,12 @@ public class TtMaServiceImpl implements TtMaService, RequestHttp<CloseableHttpCl |
|
|
|
params.put("secret", config.getSecret()); |
|
|
|
params.put("code", jsCode); |
|
|
|
|
|
|
|
String result =post(this.JSCODE_TO_SESSION_URL,params); |
|
|
|
String result = post(this.JSCODE_TO_SESSION_URL, params); |
|
|
|
JSONObject jsonObject = JSON.parseObject(result); |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
|
|
|
|
// String result = get(JSCODE_TO_SESSION_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); |
|
|
|
return WxMaJscode2SessionResult.fromJson(result); |
|
|
|
return WxMaJscode2SessionResult.fromJson(data.toJSONString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|