Package com.foxinmy.weixin4j.http.weixin
Class WeixinRequestExecutor
- java.lang.Object
-
- com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor
-
public class WeixinRequestExecutor extends Object
负责微信请求的执行- Since:
- JDK 1.6
- Author:
- jinyu(foxinmy@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected InternalLogger
logger
-
Constructor Summary
Constructors Constructor Description WeixinRequestExecutor()
WeixinRequestExecutor(HttpParams params)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WeixinRequestExecutor
createSSLRequestExecutor(String password, InputStream inputStream)
创建 SSL微信请求对象WeixinRequestExecutor
createSSLRequestExecutor(String password, String pemCertificate, String pemPrivateKey)
使用PEM格式证书创建SSL微信请求对象WeixinRequestExecutor
createSSLRequestExecutor(SSLContext sslContext)
WeixinResponse
doRequest(HttpRequest request)
执行微信请求protected static X509Certificate
generateCertificateFromDER(byte[] certBytes)
WeixinResponse
get(String url, URLParameter... parameters)
Get方法执行微信请求HttpClient
getExecuteClient()
protected void
handleResponse(WeixinResponse response)
handle the weixin responseWeixinResponse
post(String url, FormBodyPart... bodyParts)
Post方法执行微信请求,用于文件上传WeixinResponse
post(String url, String body)
Post方法执行微信请求
-
-
-
Field Detail
-
logger
protected final InternalLogger logger
-
-
Constructor Detail
-
WeixinRequestExecutor
public WeixinRequestExecutor()
-
WeixinRequestExecutor
public WeixinRequestExecutor(HttpParams params)
-
-
Method Detail
-
post
public WeixinResponse post(String url, String body) throws WeixinException
Post方法执行微信请求- Parameters:
url
- 请求URLbody
- 参数内容- Returns:
- 微信响应
- Throws:
WeixinException
-
post
public WeixinResponse post(String url, FormBodyPart... bodyParts) throws WeixinException
Post方法执行微信请求,用于文件上传- Parameters:
url
- 请求URLbodyParts
- 文件内容- Returns:
- 微信响应
- Throws:
WeixinException
-
get
public WeixinResponse get(String url, URLParameter... parameters) throws WeixinException
Get方法执行微信请求- Parameters:
url
- 请求URL,如:https://api.weixin.qq.com/cgi-bin/tokenparameters
- url上的参数,如:new URLParameter("appid",xxxxx)- Returns:
- 微信响应
- Throws:
WeixinException
-
doRequest
public WeixinResponse doRequest(HttpRequest request) throws WeixinException
执行微信请求- Parameters:
request
- 微信请求- Returns:
- 微信响应
- Throws:
WeixinException
-
handleResponse
protected void handleResponse(WeixinResponse response) throws WeixinException
handle the weixin response- Parameters:
response
- 微信请求响应- Throws:
WeixinException
-
getExecuteClient
public HttpClient getExecuteClient()
-
createSSLRequestExecutor
public WeixinRequestExecutor createSSLRequestExecutor(String password, InputStream inputStream) throws WeixinException
创建 SSL微信请求对象- Parameters:
password
- 加载密钥inputStream
- 密钥内容- Returns:
- 微信请求
- Throws:
WeixinException
-
createSSLRequestExecutor
public WeixinRequestExecutor createSSLRequestExecutor(SSLContext sslContext)
-
createSSLRequestExecutor
public WeixinRequestExecutor createSSLRequestExecutor(String password, String pemCertificate, String pemPrivateKey) throws WeixinException
使用PEM格式证书创建SSL微信请求对象- Parameters:
pemCertificate
- PEM格式证书内容pemPrivateKey
- PEM格式证书私钥- Returns:
- Throws:
WeixinException
-
generateCertificateFromDER
protected static X509Certificate generateCertificateFromDER(byte[] certBytes) throws CertificateException
- Throws:
CertificateException
-
-