11package me .chanjar .weixin .mp .api .impl ;
22
3+ import java .io .IOException ;
4+
5+ import org .apache .http .HttpHost ;
6+ import org .apache .http .client .config .RequestConfig ;
7+ import org .apache .http .client .methods .CloseableHttpResponse ;
8+ import org .apache .http .client .methods .HttpGet ;
9+ import org .apache .http .conn .ssl .DefaultHostnameVerifier ;
10+ import org .apache .http .conn .ssl .SSLConnectionSocketFactory ;
11+ import org .apache .http .impl .client .BasicResponseHandler ;
12+ import org .apache .http .impl .client .CloseableHttpClient ;
13+ import org .slf4j .Logger ;
14+ import org .slf4j .LoggerFactory ;
15+
316import com .google .gson .JsonArray ;
417import com .google .gson .JsonElement ;
518import com .google .gson .JsonObject ;
619import com .google .gson .JsonParser ;
20+
721import me .chanjar .weixin .common .bean .WxAccessToken ;
822import me .chanjar .weixin .common .bean .WxJsapiSignature ;
923import me .chanjar .weixin .common .bean .result .WxError ;
1226import me .chanjar .weixin .common .session .WxSessionManager ;
1327import me .chanjar .weixin .common .util .RandomUtils ;
1428import me .chanjar .weixin .common .util .crypto .SHA1 ;
15- import me .chanjar .weixin .common .util .http .*;
16- import me .chanjar .weixin .mp .api .*;
17- import me .chanjar .weixin .mp .bean .*;
18- import me .chanjar .weixin .mp .bean .result .*;
19- import org .apache .http .HttpHost ;
20- import org .apache .http .client .config .RequestConfig ;
21- import org .apache .http .client .methods .CloseableHttpResponse ;
22- import org .apache .http .client .methods .HttpGet ;
23- import org .apache .http .conn .ssl .DefaultHostnameVerifier ;
24- import org .apache .http .conn .ssl .SSLConnectionSocketFactory ;
25- import org .apache .http .impl .client .BasicResponseHandler ;
26- import org .apache .http .impl .client .CloseableHttpClient ;
27- import org .slf4j .Logger ;
28- import org .slf4j .LoggerFactory ;
29-
30- import java .io .IOException ;
29+ import me .chanjar .weixin .common .util .http .ApacheHttpClientBuilder ;
30+ import me .chanjar .weixin .common .util .http .DefaultApacheHttpClientBuilder ;
31+ import me .chanjar .weixin .common .util .http .RequestExecutor ;
32+ import me .chanjar .weixin .common .util .http .SimpleGetRequestExecutor ;
33+ import me .chanjar .weixin .common .util .http .SimplePostRequestExecutor ;
34+ import me .chanjar .weixin .common .util .http .URIUtil ;
35+ import me .chanjar .weixin .mp .api .WxMpCardService ;
36+ import me .chanjar .weixin .mp .api .WxMpConfigStorage ;
37+ import me .chanjar .weixin .mp .api .WxMpDataCubeService ;
38+ import me .chanjar .weixin .mp .api .WxMpKefuService ;
39+ import me .chanjar .weixin .mp .api .WxMpMaterialService ;
40+ import me .chanjar .weixin .mp .api .WxMpMenuService ;
41+ import me .chanjar .weixin .mp .api .WxMpPayService ;
42+ import me .chanjar .weixin .mp .api .WxMpQrcodeService ;
43+ import me .chanjar .weixin .mp .api .WxMpService ;
44+ import me .chanjar .weixin .mp .api .WxMpStoreService ;
45+ import me .chanjar .weixin .mp .api .WxMpUserBlacklistService ;
46+ import me .chanjar .weixin .mp .api .WxMpUserService ;
47+ import me .chanjar .weixin .mp .api .WxMpUserTagService ;
48+ import me .chanjar .weixin .mp .bean .WxMpIndustry ;
49+ import me .chanjar .weixin .mp .bean .WxMpMassNews ;
50+ import me .chanjar .weixin .mp .bean .WxMpMassOpenIdsMessage ;
51+ import me .chanjar .weixin .mp .bean .WxMpMassPreviewMessage ;
52+ import me .chanjar .weixin .mp .bean .WxMpMassTagMessage ;
53+ import me .chanjar .weixin .mp .bean .WxMpMassVideo ;
54+ import me .chanjar .weixin .mp .bean .WxMpSemanticQuery ;
55+ import me .chanjar .weixin .mp .bean .WxMpTemplateMessage ;
56+ import me .chanjar .weixin .mp .bean .result .WxMpMassSendResult ;
57+ import me .chanjar .weixin .mp .bean .result .WxMpMassUploadResult ;
58+ import me .chanjar .weixin .mp .bean .result .WxMpOAuth2AccessToken ;
59+ import me .chanjar .weixin .mp .bean .result .WxMpSemanticQueryResult ;
60+ import me .chanjar .weixin .mp .bean .result .WxMpUser ;
3161
3262public class WxMpServiceImpl implements WxMpService {
3363
@@ -178,35 +208,35 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
178208 @ Override
179209 public WxMpMassUploadResult massNewsUpload (WxMpMassNews news ) throws WxErrorException {
180210 String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews" ;
181- String responseContent = execute ( new SimplePostRequestExecutor (), url , news .toJson ());
211+ String responseContent = this . post ( url , news .toJson ());
182212 return WxMpMassUploadResult .fromJson (responseContent );
183213 }
184214
185215 @ Override
186216 public WxMpMassUploadResult massVideoUpload (WxMpMassVideo video ) throws WxErrorException {
187217 String url = "https://api.weixin.qq.com/cgi-bin/media/uploadvideo" ;
188- String responseContent = execute ( new SimplePostRequestExecutor (), url , video .toJson ());
218+ String responseContent = this . post ( url , video .toJson ());
189219 return WxMpMassUploadResult .fromJson (responseContent );
190220 }
191221
192222 @ Override
193223 public WxMpMassSendResult massGroupMessageSend (WxMpMassTagMessage message ) throws WxErrorException {
194224 String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall" ;
195- String responseContent = execute ( new SimplePostRequestExecutor (), url , message .toJson ());
225+ String responseContent = this . post ( url , message .toJson ());
196226 return WxMpMassSendResult .fromJson (responseContent );
197227 }
198228
199229 @ Override
200230 public WxMpMassSendResult massOpenIdsMessageSend (WxMpMassOpenIdsMessage message ) throws WxErrorException {
201231 String url = "https://api.weixin.qq.com/cgi-bin/message/mass/send" ;
202- String responseContent = execute ( new SimplePostRequestExecutor (), url , message .toJson ());
232+ String responseContent = this . post ( url , message .toJson ());
203233 return WxMpMassSendResult .fromJson (responseContent );
204234 }
205235
206236 @ Override
207237 public WxMpMassSendResult massMessagePreview (WxMpMassPreviewMessage wxMpMassPreviewMessage ) throws Exception {
208238 String url = "https://api.weixin.qq.com/cgi-bin/message/mass/preview" ;
209- String responseContent = execute ( new SimplePostRequestExecutor (), url , wxMpMassPreviewMessage .toJson ());
239+ String responseContent = this . post ( url , wxMpMassPreviewMessage .toJson ());
210240 return WxMpMassSendResult .fromJson (responseContent );
211241 }
212242
@@ -216,7 +246,7 @@ public String shortUrl(String long_url) throws WxErrorException {
216246 JsonObject o = new JsonObject ();
217247 o .addProperty ("action" , "long2short" );
218248 o .addProperty ("long_url" , long_url );
219- String responseContent = execute ( new SimplePostRequestExecutor (), url , o .toString ());
249+ String responseContent = this . post ( url , o .toString ());
220250 JsonElement tmpJsonElement = JSON_PARSER .parse (responseContent );
221251 return tmpJsonElement .getAsJsonObject ().get ("short_url" ).getAsString ();
222252 }
@@ -240,20 +270,20 @@ public String setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException {
240270 throw new IllegalArgumentException ("industry id is empty" );
241271 }
242272 String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry" ;
243- return execute ( new SimplePostRequestExecutor (), url , wxMpIndustry .toJson ());
273+ return this . post ( url , wxMpIndustry .toJson ());
244274 }
245275
246276 @ Override
247277 public WxMpIndustry getIndustry () throws WxErrorException {
248278 String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry" ;
249- String responseContent = execute ( new SimpleGetRequestExecutor (), url , null );
279+ String responseContent = this . get ( url , null );
250280 return WxMpIndustry .fromJson (responseContent );
251281 }
252282
253283 @ Override
254284 public WxMpSemanticQueryResult semanticQuery (WxMpSemanticQuery semanticQuery ) throws WxErrorException {
255285 String url = "https://api.weixin.qq.com/semantic/semproxy/search" ;
256- String responseContent = execute ( new SimplePostRequestExecutor (), url , semanticQuery .toJson ());
286+ String responseContent = this . post ( url , semanticQuery .toJson ());
257287 return WxMpSemanticQueryResult .fromJson (responseContent );
258288 }
259289
0 commit comments