public class DefaultTaobaoClient extends Object implements TaobaoClient
| Modifier and Type | Field and Description |
|---|---|
protected String |
appKey |
protected String |
appSecret |
protected int |
connectTimeout |
protected String |
format |
protected boolean |
needCheckRequest |
protected boolean |
needEnableParser |
protected int |
readTimeout |
protected String |
serverUrl |
protected String |
signMethod |
protected boolean |
useGzipEncoding |
protected boolean |
useSimplifyJson |
| Constructor and Description |
|---|
DefaultTaobaoClient(String serverUrl,
String appKey,
String appSecret) |
DefaultTaobaoClient(String serverUrl,
String appKey,
String appSecret,
String format) |
DefaultTaobaoClient(String serverUrl,
String appKey,
String appSecret,
String format,
int connectTimeout,
int readTimeout) |
DefaultTaobaoClient(String serverUrl,
String appKey,
String appSecret,
String format,
int connectTimeout,
int readTimeout,
String signMethod) |
| Modifier and Type | Method and Description |
|---|---|
void |
enableHttpDns()
启用http dns
|
void |
enableHttpDns(String onlineAppKey,
String onlineAppSecret)
沙箱环境启用http dns
|
<T extends TaobaoResponse> |
execute(TaobaoRequest<T> request)
执行公开API请求。
|
<T extends TaobaoResponse> |
execute(TaobaoRequest<T> request,
String session)
执行隐私API请求。
|
String |
getAppKey() |
String |
getAppSecret() |
int |
getConnectTimeout() |
String |
getFormat() |
Proxy |
getProxy() |
int |
getReadTimeout() |
protected String |
getRealResponseType(String format,
String responseType) |
String |
getRequestUrl() |
String |
getSdkVersion() |
String |
getServerUrl(String serverUrl,
String apiName,
String session,
TaobaoHashMap appParams) |
String |
getSignMethod() |
String |
getTopHttpDnsHost() |
protected RequestParametersHolder |
invokeApi(RequestDTO request,
String session,
long start) |
boolean |
isNeedCheckRequest() |
boolean |
isNeedEnableParser() |
boolean |
isUseGzipEncoding() |
boolean |
isUseSimplifyJson() |
void |
resetServerUrl(String serverUrl) |
void |
setConnectTimeout(int connectTimeout)
设置API请求的连接超时时间,默认为15秒。
|
void |
setIgnoreSSLCheck(boolean ignore)
是否忽略HTTPS证书校验。
|
void |
setNeedCheckRequest(boolean needCheckRequest)
是否在客户端校验请求参数。
|
void |
setNeedEnableLogger(boolean needEnableLogger)
是否记录API请求错误日志。
|
void |
setNeedEnableParser(boolean needEnableParser)
是否把响应字符串解释为对象。
|
void |
setProxy(Proxy proxy) |
void |
setReadTimeout(int readTimeout)
设置API请求的读超时时间,默认为30秒。
|
protected void |
setRealFormat(String responseType) |
void |
setUseGzipEncoding(boolean useGzipEncoding)
是否启用响应GZIP压缩
|
void |
setUseSimplifyJson(boolean useSimplifyJson)
是否采用标准化的JSON格式返回。
|
protected String serverUrl
protected String appKey
protected String appSecret
protected String format
protected String signMethod
protected int connectTimeout
protected int readTimeout
protected boolean needCheckRequest
protected boolean needEnableParser
protected boolean useSimplifyJson
protected boolean useGzipEncoding
public DefaultTaobaoClient(String serverUrl, String appKey, String appSecret, String format)
public DefaultTaobaoClient(String serverUrl, String appKey, String appSecret, String format, int connectTimeout, int readTimeout)
public <T extends TaobaoResponse> T execute(TaobaoRequest<T> request) throws ApiException
TaobaoClientexecute in interface TaobaoClientT - 具体的API响应类request - 具体的API请求类ApiExceptionpublic <T extends TaobaoResponse> T execute(TaobaoRequest<T> request, String session) throws ApiException
TaobaoClientexecute in interface TaobaoClientT - 具体的API响应类request - 具体的API请求类session - 用户授权码ApiExceptionpublic String getServerUrl(String serverUrl, String apiName, String session, TaobaoHashMap appParams)
public String getSdkVersion()
public void setNeedCheckRequest(boolean needCheckRequest)
public void setNeedEnableParser(boolean needEnableParser)
public void setUseSimplifyJson(boolean useSimplifyJson)
public void setNeedEnableLogger(boolean needEnableLogger)
public void setIgnoreSSLCheck(boolean ignore)
public void setUseGzipEncoding(boolean useGzipEncoding)
public void setConnectTimeout(int connectTimeout)
public void setReadTimeout(int readTimeout)
public String getTopHttpDnsHost()
public void enableHttpDns()
public void enableHttpDns(String onlineAppKey, String onlineAppSecret)
onlineAppKey - 正式keyonlineAppSecret - 正式环境secretpublic void resetServerUrl(String serverUrl)
public String getRequestUrl()
public String getAppKey()
protected RequestParametersHolder invokeApi(RequestDTO request, String session, long start) throws ApiException
ApiExceptionprotected void setRealFormat(String responseType)
public Proxy getProxy()
public void setProxy(Proxy proxy)
public String getAppSecret()
public String getFormat()
public String getSignMethod()
public int getConnectTimeout()
public int getReadTimeout()
public boolean isNeedCheckRequest()
public boolean isUseSimplifyJson()
public boolean isUseGzipEncoding()
public boolean isNeedEnableParser()
Copyright © 2021. All rights reserved.