repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpResponseProxy.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpResponseProxy.java | package me.chanjar.weixin.common.util.http.apache;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;
public class ApacheHttpResponseProxy implements HttpResponseProxy {
private final CloseableHttpResponse httpResponse;
public ApacheHttpResponseProxy(CloseableHttpResponse closeableHttpResponse) {
this.httpResponse = closeableHttpResponse;
}
@Override
public String getFileName() throws WxErrorException {
Header[] contentDispositionHeader = this.httpResponse.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException("无法获取到文件名,Content-disposition为空");
}
return HttpResponseProxy.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java | package me.chanjar.weixin.common.util.http.apache;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
/**
* httpclient build interface.
*
* @author kakotor
*/
public interface ApacheHttpClientBuilder {
/**
* 构建httpclient实例.
*
* @return new instance of CloseableHttpClient
*/
CloseableHttpClient build();
/**
* 代理服务器地址.
*/
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口.
*/
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名.
*/
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码.
*/
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword);
/**
* 重试策略.
*/
ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler );
/**
* 超时时间.
*/
ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy);
/**
* ssl连接socket工厂.
*/
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
/**
* 支持的TLS协议版本.
* Supported TLS protocol versions.
*/
ApacheHttpClientBuilder supportedProtocols(String[] supportedProtocols);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java | package me.chanjar.weixin.common.util.http.apache;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/4
*/
public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheSimplePostRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (postEntity != null) {
StringEntity entity = new StringEntity(postEntity, ContentType.APPLICATION_JSON.withCharset(StandardCharsets.UTF_8));
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
return this.handleResponse(wxType, responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMinishopMediaUploadRequestCustomizeExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMinishopMediaUploadRequestCustomizeExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
/**
* ApacheMinishopMediaUploadRequestCustomizeExecutor
*
* @author altusea
*/
@Slf4j
public class HttpComponentsMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, String respType, String imgUrl) {
super(requestHttp, respType, imgUrl);
}
@Override
public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (this.uploadType.equals("0")) {
if (file == null) {
throw new WxErrorException("上传文件为空");
}
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.addTextBody("resp_type", this.respType)
.addTextBody("upload_type", this.uploadType)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
else {
HttpEntity entity = MultipartEntityBuilder
.create()
.addTextBody("resp_type", this.respType)
.addTextBody("upload_type", this.uploadType)
.addTextBody("img_url", this.imgUrl)
.setMode(org.apache.hc.client5.http.entity.mime.HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadCustomizeResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaDownloadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaDownloadRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* ApacheMediaDownloadRequestExecutor
*
* @author altusea
*/
public class HttpComponentsMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@Override
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
HttpGet httpGet = new HttpGet(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet);
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) {
Header[] contentTypeHeader = response.getHeaders("Content-Type");
if (contentTypeHeader != null && contentTypeHeader.length > 0) {
if (contentTypeHeader[0].getValue().startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
// application/json; encoding=utf-8 下载媒体文件出错
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
throw new WxErrorException(WxError.fromJson(responseContent, wxType));
}
}
String fileName = HttpResponseProxy.from(response).getFileName();
if (StringUtils.isBlank(fileName)) {
fileName = String.valueOf(System.currentTimeMillis());
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
return FileUtils.createTmpFile(inputStream, baseName, FilenameUtils.getExtension(fileName), super.tmpDirFile);
} catch (HttpException httpException) {
throw new ClientProtocolException(httpException.getMessage(), httpException);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaInputStreamUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaInputStreamUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.InputStreamData;
import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.IOException;
/**
* 文件输入流上传.
*
* @author altusea
*/
public class HttpComponentsMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMediaInputStreamUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (data != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFilename())
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/ByteArrayResponseHandler.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/ByteArrayResponseHandler.java | package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import java.io.IOException;
/**
* ByteArrayResponseHandler
*
* @author altusea
*/
public class ByteArrayResponseHandler extends AbstractHttpClientResponseHandler<byte[]> {
public static final ByteArrayResponseHandler INSTANCE = new ByteArrayResponseHandler();
@Override
public byte[] handleEntity(HttpEntity entity) throws IOException {
return EntityUtils.toByteArray(entity);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMinishopMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMinishopMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
/**
* ApacheMinishopMediaUploadRequestExecutor
*
* @author altusea
*/
@Slf4j
public class HttpComponentsMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMinishopMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/InputStreamResponseHandler.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/InputStreamResponseHandler.java | package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.io.HttpClientResponseHandler;
import java.io.IOException;
import java.io.InputStream;
/**
* InputStreamResponseHandler
*
* @author altusea
*/
public class InputStreamResponseHandler extends AbstractHttpClientResponseHandler<InputStream> {
public static final HttpClientResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler();
@Override
public InputStream handleEntity(HttpEntity entity) throws IOException {
return entity.getContent();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/Utf8ResponseHandler.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/Utf8ResponseHandler.java | package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.HttpClientResponseHandler;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* Utf8ResponseHandler
*
* @author altusea
*/
public class Utf8ResponseHandler extends AbstractHttpClientResponseHandler<String> {
public static final HttpClientResponseHandler<String> INSTANCE = new Utf8ResponseHandler();
@Override
public String handleEntity(HttpEntity entity) throws IOException {
try {
return EntityUtils.toString(entity, StandardCharsets.UTF_8);
} catch (final ParseException ex) {
throw new ClientProtocolException(ex);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/BasicResponseHandler.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/BasicResponseHandler.java | package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
/**
* ApacheBasicResponseHandler
*
* @author altusea
*/
public class BasicResponseHandler extends BasicHttpClientResponseHandler {
public static final BasicHttpClientResponseHandler INSTANCE = new BasicHttpClientResponseHandler();
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsSimplePostRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsSimplePostRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.StringEntity;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* ApacheSimplePostRequestExecutor
*
* @author altusea
*/
public class HttpComponentsSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsSimplePostRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (postEntity != null) {
StringEntity entity = new StringEntity(postEntity, ContentType.APPLICATION_JSON.withCharset(StandardCharsets.UTF_8));
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
return this.handleResponse(wxType, responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
/**
* ApacheMediaUploadRequestExecutor
*
* @author altusea
*/
public class HttpComponentsMediaUploadRequestExecutor extends MediaUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsResponseProxy.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsResponseProxy.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.Header;
public class HttpComponentsResponseProxy implements HttpResponseProxy {
private final CloseableHttpResponse response;
public HttpComponentsResponseProxy(CloseableHttpResponse closeableHttpResponse) {
this.response = closeableHttpResponse;
}
@Override
public String getFileName() throws WxErrorException {
Header[] contentDispositionHeader = this.response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException("无法获取到文件名,Content-disposition为空");
}
return HttpResponseProxy.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsClientBuilder.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
/**
* httpclient build interface.
*
* @author altusea
*/
public interface HttpComponentsClientBuilder {
/**
* 构建httpclient实例.
*
* @return new instance of CloseableHttpClient
*/
CloseableHttpClient build();
/**
* 代理服务器地址.
*/
HttpComponentsClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口.
*/
HttpComponentsClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名.
*/
HttpComponentsClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码.
*/
HttpComponentsClientBuilder httpProxyPassword(char[] httpProxyPassword);
/**
* 重试策略.
*/
HttpComponentsClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy);
/**
* 超时时间.
*/
HttpComponentsClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/NoopRetryStrategy.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/NoopRetryStrategy.java | package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.TimeValue;
import java.io.IOException;
/**
* NoopRetryStrategy
*
* @author altusea
*/
public class NoopRetryStrategy implements HttpRequestRetryStrategy {
public static final HttpRequestRetryStrategy INSTANCE = new NoopRetryStrategy();
@Override
public boolean retryRequest(HttpRequest request, IOException exception, int execCount, HttpContext context) {
return false;
}
@Override
public boolean retryRequest(HttpResponse response, int execCount, HttpContext context) {
return false;
}
@Override
public TimeValue getRetryInterval(HttpResponse response, int execCount, HttpContext context) {
return TimeValue.ZERO_MILLISECONDS;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsSimpleGetRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsSimpleGetRequestExecutor.java | package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpHost;
import java.io.IOException;
/**
* ApacheSimpleGetRequestExecutor
*
* @author altusea
*/
public class HttpComponentsSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsSimpleGetRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
HttpGet httpGet = new HttpGet(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpGet, Utf8ResponseHandler.INSTANCE);
return handleResponse(wxType, responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/DefaultHttpComponentsClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/DefaultHttpComponentsClientBuilder.java | package me.chanjar.weixin.common.util.http.hc;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.HttpResponseInterceptor;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.ssl.SSLContexts;
import javax.annotation.concurrent.NotThreadSafe;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* DefaultApacheHttpClientBuilder
*
* @author altusea
*/
@Slf4j
@Data
@NotThreadSafe
public class DefaultHttpComponentsClientBuilder implements HttpComponentsClientBuilder {
private final AtomicBoolean prepared = new AtomicBoolean(false);
/**
* 获取链接的超时时间设置
* <p>
* 设置为零时不超时,一直等待.
* 设置为负数是使用系统默认设置(非3000ms的默认值,而是httpClient的默认设置).
* </p>
*/
private int connectionRequestTimeout = 3000;
/**
* 建立链接的超时时间,默认为5000ms.由于是在链接池获取链接,此设置应该并不起什么作用
* <p>
* 设置为零时不超时,一直等待.
* 设置为负数是使用系统默认设置(非上述的5000ms的默认值,而是httpclient的默认设置).
* </p>
*/
private int connectionTimeout = 5000;
/**
* 默认NIO的socket超时设置,默认5000ms.
*/
private int soTimeout = 5000;
/**
* 空闲链接的超时时间,默认60000ms.
* <p>
* 超时的链接将在下一次空闲链接检查是被销毁
* </p>
*/
private int idleConnTimeout = 60000;
/**
* 检查空间链接的间隔周期,默认60000ms.
*/
private int checkWaitTime = 60000;
/**
* 每路的最大链接数,默认10
*/
private int maxConnPerHost = 10;
/**
* 最大总连接数,默认50
*/
private int maxTotalConn = 50;
/**
* 自定义httpclient的User Agent
*/
private String userAgent;
/**
* 自定义请求拦截器
*/
private List<HttpRequestInterceptor> requestInterceptors = new ArrayList<>();
/**
* 自定义响应拦截器
*/
private List<HttpResponseInterceptor> responseInterceptors = new ArrayList<>();
/**
* 自定义重试策略
*/
private HttpRequestRetryStrategy httpRequestRetryStrategy;
/**
* 自定义KeepAlive策略
*/
private ConnectionKeepAliveStrategy connectionKeepAliveStrategy;
private String httpProxyHost;
private int httpProxyPort;
private String httpProxyUsername;
private char[] httpProxyPassword;
/**
* 持有client对象,仅初始化一次,避免多service实例的时候造成重复初始化的问题
*/
private CloseableHttpClient closeableHttpClient;
private DefaultHttpComponentsClientBuilder() {
}
public static DefaultHttpComponentsClientBuilder get() {
return SingletonHolder.INSTANCE;
}
@Override
public HttpComponentsClientBuilder httpProxyHost(String httpProxyHost) {
this.httpProxyHost = httpProxyHost;
return this;
}
@Override
public HttpComponentsClientBuilder httpProxyPort(int httpProxyPort) {
this.httpProxyPort = httpProxyPort;
return this;
}
@Override
public HttpComponentsClientBuilder httpProxyUsername(String httpProxyUsername) {
this.httpProxyUsername = httpProxyUsername;
return this;
}
@Override
public HttpComponentsClientBuilder httpProxyPassword(char[] httpProxyPassword) {
this.httpProxyPassword = httpProxyPassword;
return this;
}
@Override
public HttpComponentsClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy) {
this.httpRequestRetryStrategy = httpRequestRetryStrategy;
return this;
}
@Override
public HttpComponentsClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
this.connectionKeepAliveStrategy = keepAliveStrategy;
return this;
}
private synchronized void prepare() {
if (prepared.get()) {
return;
}
SSLContext sslcontext;
try {
sslcontext = SSLContexts.custom()
.loadTrustMaterial(TrustAllStrategy.INSTANCE) // 忽略对服务器端证书的校验
.build();
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
log.error("构建 SSLContext 时发生异常!", e);
throw new RuntimeException(e);
}
PoolingHttpClientConnectionManager connManager = PoolingHttpClientConnectionManagerBuilder.create()
.setTlsSocketStrategy(new DefaultClientTlsStrategy(sslcontext, NoopHostnameVerifier.INSTANCE))
.setMaxConnTotal(this.maxTotalConn)
.setMaxConnPerRoute(this.maxConnPerHost)
.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(this.soTimeout, TimeUnit.MILLISECONDS)
.build())
.setDefaultConnectionConfig(ConnectionConfig.custom()
.setConnectTimeout(this.connectionTimeout, TimeUnit.MILLISECONDS)
.build())
.build();
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setConnectionManager(connManager)
.setConnectionManagerShared(true)
.setDefaultRequestConfig(RequestConfig.custom()
.setConnectionRequestTimeout(this.connectionRequestTimeout, TimeUnit.MILLISECONDS)
.build()
);
// 设置重试策略,没有则使用默认
httpClientBuilder.setRetryStrategy(ObjectUtils.defaultIfNull(httpRequestRetryStrategy, NoopRetryStrategy.INSTANCE));
// 设置KeepAliveStrategy,没有使用默认
if (connectionKeepAliveStrategy != null) {
httpClientBuilder.setKeepAliveStrategy(connectionKeepAliveStrategy);
}
if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) {
// 使用代理服务器 需要用户认证的代理服务器
BasicCredentialsProvider provider = new BasicCredentialsProvider();
provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort),
new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword));
httpClientBuilder.setDefaultCredentialsProvider(provider);
httpClientBuilder.setProxy(new HttpHost(this.httpProxyHost, this.httpProxyPort));
}
if (StringUtils.isNotBlank(this.userAgent)) {
httpClientBuilder.setUserAgent(this.userAgent);
}
//添加自定义的请求拦截器
requestInterceptors.forEach(httpClientBuilder::addRequestInterceptorFirst);
//添加自定义的响应拦截器
responseInterceptors.forEach(httpClientBuilder::addResponseInterceptorLast);
this.closeableHttpClient = httpClientBuilder.build();
prepared.set(true);
}
@Override
public CloseableHttpClient build() {
if (!prepared.get()) {
prepare();
}
return this.closeableHttpClient;
}
/**
* DefaultApacheHttpClientBuilder 改为单例模式,并持有唯一的CloseableHttpClient(仅首次调用创建)
*/
private static class SingletonHolder {
private static final DefaultHttpComponentsClientBuilder INSTANCE = new DefaultHttpComponentsClientBuilder();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpClientBuilder.java | package me.chanjar.weixin.common.util.http.okhttp;
import okhttp3.*;
import java.net.Proxy;
import java.util.concurrent.TimeUnit;
/**
* @author wulang
**/
public interface OkHttpClientBuilder {
/**
* 构建OkHttpClient实例.
*
* @return OkHttpClient
*/
OkHttpClient build();
/**
* 代理
*
* @param proxy Proxy
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder proxy(Proxy proxy);
/**
* 授权
*
* @param authenticator Authenticator
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder authenticator(Authenticator authenticator);
/**
* 拦截器
*
* @param interceptor Interceptor
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder addInterceptor(Interceptor interceptor);
/**
* 请求调度管理
*
* @param dispatcher Dispatcher
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setDispatcher(Dispatcher dispatcher);
/**
* 连接池
*
* @param connectionPool ConnectionPool
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool);
/**
* 监听网络请求过程
*
* @param eventListenerFactory EventListener
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory);
/**
* 是否支持失败重连
*
* @param retryOnConnectionFailure retryOnConnectionFailure
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure);
/**
* 是否允许重定向操作
*
* @param followRedirects followRedirects
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setFollowRedirects(Boolean followRedirects);
/**
* 连接建立的超时时间
*
* @param timeout 时长
* @param unit 时间单位
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit);
/**
* 完整的请求过程超时时间
*
* @param timeout 时长
* @param unit 时间单位
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit);
/**
* 连接的IO读操作超时时间
*
* @param timeout 时长
* @param unit 时间单位
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit);
/**
* 连接的IO写操作超时时间
*
* @param timeout 时长
* @param unit 时间单位
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit);
/**
* ping的时间间隔
*
* @param pingInterval ping的时间间隔
* @return OkHttpClientBuilder
*/
OkHttpClientBuilder setPingInterval(Integer pingInterval);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okio.BufferedSink;
import okio.Okio;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
/**
*.
* @author ecoolper
* created on 2017/5/5
*/
@Slf4j
public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMediaDownloadRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@Override
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
//得到httpClient
OkHttpClient client = requestHttp.getRequestHttpClient();
Request request = new Request.Builder().url(uri).get().build();
Response response = client.newCall(request).execute();
String contentType = response.header("Content-Type");
if (contentType != null && contentType.startsWith("application/json")) {
// application/json; encoding=utf-8 下载媒体文件出错
throw new WxErrorException(WxError.fromJson(response.body().string(), wxType));
}
String fileName = HttpResponseProxy.from(response).getFileName();
if (StringUtils.isBlank(fileName)) {
return null;
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
File file = File.createTempFile(
baseName, "." + FilenameUtils.getExtension(fileName), super.tmpDirFile
);
try (BufferedSink sink = Okio.buffer(Okio.sink(file))) {
sink.writeAll(response.body().source());
}
file.deleteOnExit();
return file;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java | package me.chanjar.weixin.common.util.http.okhttp;
import java.net.InetSocketAddress;
import java.net.Proxy;
/**
* Created by ecoolper on 2017/4/26.
* Proxy information.
*/
public class OkHttpProxyInfo {
private final String proxyAddress;
private final int proxyPort;
private final String proxyUsername;
private final String proxyPassword;
private final ProxyType proxyType;
public OkHttpProxyInfo(ProxyType proxyType, String proxyHost, int proxyPort, String proxyUser, String proxyPassword) {
this.proxyType = proxyType;
this.proxyAddress = proxyHost;
this.proxyPort = proxyPort;
this.proxyUsername = proxyUser;
this.proxyPassword = proxyPassword;
}
/**
* Creates directProxy.
*/
public static OkHttpProxyInfo directProxy() {
return new OkHttpProxyInfo(ProxyType.NONE, null, 0, null, null);
}
// ---------------------------------------------------------------- factory
/**
* Creates SOCKS4 proxy.
*/
public static OkHttpProxyInfo socks4Proxy(String proxyAddress, int proxyPort, String proxyUser) {
return new OkHttpProxyInfo(ProxyType.SOCKS4, proxyAddress, proxyPort, proxyUser, null);
}
/**
* Creates SOCKS5 proxy.
*/
public static OkHttpProxyInfo socks5Proxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) {
return new OkHttpProxyInfo(ProxyType.SOCKS5, proxyAddress, proxyPort, proxyUser, proxyPassword);
}
/**
* Creates HTTP proxy.
*/
public static OkHttpProxyInfo httpProxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) {
return new OkHttpProxyInfo(ProxyType.HTTP, proxyAddress, proxyPort, proxyUser, proxyPassword);
}
/**
* Returns proxy type.
*/
public ProxyType getProxyType() {
return proxyType;
}
// ---------------------------------------------------------------- getter
/**
* Returns proxy address.
*/
public String getProxyAddress() {
return proxyAddress;
}
/**
* Returns proxy port.
*/
public int getProxyPort() {
return proxyPort;
}
/**
* Returns proxy user name or <code>null</code> if
* no authentication required.
*/
public String getProxyUsername() {
return proxyUsername;
}
/**
* Returns proxy password or <code>null</code>.
*/
public String getProxyPassword() {
return proxyPassword;
}
/**
* 返回 java.net.Proxy
*/
public Proxy getProxy() {
Proxy proxy = null;
if (getProxyType().equals(ProxyType.SOCKS5)) {
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(getProxyAddress(), getProxyPort()));
} else if (getProxyType().equals(ProxyType.SOCKS4)) {
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(getProxyAddress(), getProxyPort()));
} else if (getProxyType().equals(ProxyType.HTTP)) {
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(getProxyAddress(), getProxyPort()));
} else if (getProxyType().equals(ProxyType.NONE)) {
proxy = new Proxy(Proxy.Type.DIRECT, new InetSocketAddress(getProxyAddress(), getProxyPort()));
}
return proxy;
}
/**
* Proxy types.
*/
public enum ProxyType {
NONE, HTTP, SOCKS4, SOCKS5
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
/**
*
*
* @author ecoolper
* created on 2017/5/4
*/
public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpSimpleGetRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
//得到httpClient
OkHttpClient client = requestHttp.getRequestHttpClient();
Request request = new Request.Builder().url(uri).build();
Response response = client.newCall(request).execute();
return this.handleResponse(wxType, response.body().string());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.*;
import java.io.File;
import java.io.IOException;
/**
* .
*
* @author ecoolper
* created on 2017/5/5
*/
@Slf4j
public class OkHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMinishopMediaUploadRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
RequestBody body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("media",
file.getName(),
RequestBody.create(MediaType.parse("application/octet-stream"), file))
.build();
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import okhttp3.*;
import java.io.IOException;
import java.util.Objects;
/**
* .
*
* @author ecoolper
* created on 2017/5/4
*/
@Slf4j
public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpSimplePostRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException {
RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("application/json; charset=utf-8"));
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
return this.handleResponse(wxType, Objects.requireNonNull(response.body()).string());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.*;
import java.io.File;
import java.io.IOException;
/**
* @author liming1019
* created on 2021/8/10
*/
@Slf4j
public class OkHttpMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp, String respType, String imgUrl) {
super(requestHttp, respType, imgUrl);
}
@Override
public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
RequestBody body = null;
if (this.uploadType.equals("0")) {
body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("resp_type", this.respType)
.addFormDataPart("upload_type", this.uploadType)
.addFormDataPart("media", file.getName(), RequestBody.create(MediaType.parse("application/octet-stream"), file))
.build();
}
else {
body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("resp_type", this.respType)
.addFormDataPart("upload_type", this.uploadType)
.addFormDataPart("img_url", this.imgUrl)
.build();
}
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadCustomizeResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.*;
import java.io.File;
import java.io.IOException;
/**
* .
*
* @author ecoolper
* created on 2017/5/5
*/
public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMediaUploadRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
RequestBody body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("media",
file.getName(),
RequestBody.create(MediaType.parse("application/octet-stream"), file))
.build();
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaInputStreamUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaInputStreamUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.okhttp;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.InputStreamData;
import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* 文件输入流上传.
*
* @author meiqin.zhou91@gmail.com
* created on 2022/02/15
*/
public class OkHttpMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMediaInputStreamUploadRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException {
RequestBody body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("media", data.getFilename(), RequestBody.create(this.toByteArray(data.getInputStream()), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
public byte[] toByteArray(InputStream input) throws IOException {
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
return output.toByteArray();
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/DefaultOkHttpClientBuilder.java | package me.chanjar.weixin.common.util.http.okhttp;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import javax.annotation.concurrent.NotThreadSafe;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author wulang
**/
@Slf4j
@Data
@NotThreadSafe
public class DefaultOkHttpClientBuilder implements OkHttpClientBuilder {
private final AtomicBoolean prepared = new AtomicBoolean(false);
/**
* 代理
*/
private Proxy proxy;
/**
* 授权
*/
private Authenticator authenticator;
/**
* 拦截器
*/
private final List<Interceptor> interceptorList = new ArrayList<>();
/**
* 请求调度管理
*/
private Dispatcher dispatcher;
/**
* 连接池
*/
private ConnectionPool connectionPool;
/**
* 监听网络请求过程
*/
private EventListener.Factory eventListenerFactory;
/**
* 是否支持失败重连
*/
private Boolean retryOnConnectionFailure;
/**
* 是否允许重定向操作
*/
private Boolean followRedirects;
/**
* 连接建立的超时时长
*/
private Long connectTimeout;
/**
* 连接建立的超时时间单位
*/
private TimeUnit connectTimeUnit;
/**
* 完整的请求过程超时时长
*/
private Long callTimeout;
/**
* 完整的请求过程超时时间单位
*/
private TimeUnit callTimeUnit;
/**
* 连接的IO读操作超时时长
*/
private Long readTimeout;
/**
* 连接的IO读操作超时时间单位
*/
private TimeUnit readTimeUnit;
/**
* 连接的IO写操作超时时长
*/
private Long writeTimeout;
/**
* 连接的IO写操作超时时间单位
*/
private TimeUnit writeTimeUnit;
/**
* ping的时间间隔
*/
private Integer pingInterval;
/**
* 持有client对象,仅初始化一次,避免多service实例的时候造成重复初始化的问题
*/
private OkHttpClient okHttpClient;
private DefaultOkHttpClientBuilder() {
}
public static DefaultOkHttpClientBuilder get() {
return DefaultOkHttpClientBuilder.SingletonHolder.INSTANCE;
}
@Override
public OkHttpClient build() {
if (!prepared.get()) {
prepare();
}
return this.okHttpClient;
}
@Override
public OkHttpClientBuilder proxy(Proxy proxy) {
this.proxy = proxy;
return this;
}
@Override
public OkHttpClientBuilder authenticator(Authenticator authenticator) {
this.authenticator = authenticator;
return this;
}
@Override
public OkHttpClientBuilder addInterceptor(Interceptor interceptor) {
this.interceptorList.add(interceptor);
return this;
}
@Override
public OkHttpClientBuilder setDispatcher(Dispatcher dispatcher) {
this.dispatcher = dispatcher;
return this;
}
@Override
public OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool) {
this.connectionPool = connectionPool;
return this;
}
@Override
public OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory) {
this.eventListenerFactory = eventListenerFactory;
return this;
}
@Override
public OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure) {
this.retryOnConnectionFailure = retryOnConnectionFailure;
return this;
}
@Override
public OkHttpClientBuilder setFollowRedirects(Boolean followRedirects) {
this.followRedirects = followRedirects;
return this;
}
@Override
public OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit) {
this.connectTimeout = timeout;
this.connectTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit) {
this.callTimeout = timeout;
this.callTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit) {
this.readTimeout = timeout;
this.readTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit) {
this.writeTimeout = timeout;
this.writeTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder setPingInterval(Integer pingInterval) {
this.pingInterval = pingInterval;
return this;
}
private synchronized void prepare() {
if (prepared.get()) {
return;
}
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (this.authenticator != null) {
builder.authenticator(this.authenticator);
}
if (this.proxy != null) {
builder.proxy(this.proxy);
}
for (Interceptor interceptor : this.interceptorList) {
builder.addInterceptor(interceptor);
}
if (this.dispatcher != null) {
builder.dispatcher(dispatcher);
}
if (this.connectionPool != null) {
builder.connectionPool(connectionPool);
}
if (this.eventListenerFactory != null) {
builder.eventListenerFactory(this.eventListenerFactory);
}
if (this.retryOnConnectionFailure != null) {
builder.setRetryOnConnectionFailure$okhttp(this.retryOnConnectionFailure);
}
if (this.followRedirects != null) {
builder.followRedirects(this.followRedirects);
}
if (this.connectTimeout != null && this.connectTimeUnit != null) {
builder.connectTimeout(this.connectTimeout, this.connectTimeUnit);
}
if (this.callTimeout != null && this.callTimeUnit != null) {
builder.callTimeout(this.callTimeout, this.callTimeUnit);
}
if (this.readTimeout != null && this.readTimeUnit != null) {
builder.readTimeout(this.readTimeout, this.readTimeUnit);
}
if (this.writeTimeout != null && this.writeTimeUnit != null) {
builder.writeTimeout(this.writeTimeout, this.writeTimeUnit);
}
if (this.pingInterval != null) {
builder.setPingInterval$okhttp(this.pingInterval);
}
this.okHttpClient = builder.build();
prepared.set(true);
}
private static class SingletonHolder {
private static final DefaultOkHttpClientBuilder INSTANCE = new DefaultOkHttpClientBuilder();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpDnsClientBuilder.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpDnsClientBuilder.java | package me.chanjar.weixin.common.util.http.okhttp;
import okhttp3.*;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* OkHttpClient 连接管理器 多一个DNS解析.
* <p>大部分代码拷贝自:DefaultOkHttpClientBuilder</p>
*
* @author wulang
**/
public class OkHttpDnsClientBuilder implements OkHttpClientBuilder {
/**
* 代理
*/
private Proxy proxy;
/**
* 授权
*/
private Authenticator authenticator;
/**
* 拦截器
*/
private final List<Interceptor> interceptorList = new ArrayList<>();
/**
* 请求调度管理
*/
private Dispatcher dispatcher;
/**
* 连接池
*/
private ConnectionPool connectionPool;
/**
* 监听网络请求过程
*/
private EventListener.Factory eventListenerFactory;
/**
* 是否支持失败重连
*/
private Boolean retryOnConnectionFailure;
/**
* 是否允许重定向操作
*/
private Boolean followRedirects;
/**
* 连接建立的超时时长
*/
private Long connectTimeout;
/**
* 连接建立的超时时间单位
*/
private TimeUnit connectTimeUnit;
/**
* 完整的请求过程超时时长
*/
private Long callTimeout;
/**
* 完整的请求过程超时时间单位
*/
private TimeUnit callTimeUnit;
/**
* 连接的IO读操作超时时长
*/
private Long readTimeout;
/**
* 连接的IO读操作超时时间单位
*/
private TimeUnit readTimeUnit;
/**
* 连接的IO写操作超时时长
*/
private Long writeTimeout;
/**
* 连接的IO写操作超时时间单位
*/
private TimeUnit writeTimeUnit;
/**
* ping的时间间隔
*/
private Integer pingInterval;
private Dns dns;
private OkHttpClient okHttpClient;
private OkHttpDnsClientBuilder() {
}
public static OkHttpDnsClientBuilder get() {
return new OkHttpDnsClientBuilder();
}
public Dns getDns() {
return dns;
}
public void setDns(Dns dns) {
this.dns = dns;
}
@Override
public OkHttpClient build() {
prepare();
return this.okHttpClient;
}
@Override
public OkHttpClientBuilder proxy(Proxy proxy) {
this.proxy = proxy;
return this;
}
@Override
public OkHttpClientBuilder authenticator(Authenticator authenticator) {
this.authenticator = authenticator;
return this;
}
@Override
public OkHttpClientBuilder addInterceptor(Interceptor interceptor) {
this.interceptorList.add(interceptor);
return this;
}
@Override
public OkHttpClientBuilder setDispatcher(Dispatcher dispatcher) {
this.dispatcher = dispatcher;
return this;
}
@Override
public OkHttpClientBuilder setConnectionPool(ConnectionPool connectionPool) {
this.connectionPool = connectionPool;
return this;
}
@Override
public OkHttpClientBuilder setEventListenerFactory(EventListener.Factory eventListenerFactory) {
this.eventListenerFactory = eventListenerFactory;
return this;
}
@Override
public OkHttpClientBuilder setRetryOnConnectionFailure(Boolean retryOnConnectionFailure) {
this.retryOnConnectionFailure = retryOnConnectionFailure;
return this;
}
@Override
public OkHttpClientBuilder setFollowRedirects(Boolean followRedirects) {
this.followRedirects = followRedirects;
return this;
}
@Override
public OkHttpClientBuilder connectTimeout(Long timeout, TimeUnit unit) {
this.connectTimeout = timeout;
this.connectTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder callTimeout(Long timeout, TimeUnit unit) {
this.callTimeout = timeout;
this.callTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder readTimeout(Long timeout, TimeUnit unit) {
this.readTimeout = timeout;
this.readTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder writeTimeout(Long timeout, TimeUnit unit) {
this.writeTimeout = timeout;
this.writeTimeUnit = unit;
return this;
}
@Override
public OkHttpClientBuilder setPingInterval(Integer pingInterval) {
this.pingInterval = pingInterval;
return this;
}
private synchronized void prepare() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (this.authenticator != null) {
builder.authenticator(this.authenticator);
}
if (this.proxy != null) {
builder.proxy(this.proxy);
}
for (Interceptor interceptor : this.interceptorList) {
builder.addInterceptor(interceptor);
}
if (this.dispatcher != null) {
builder.dispatcher(dispatcher);
}
if (this.connectionPool != null) {
builder.connectionPool(connectionPool);
}
if (this.eventListenerFactory != null) {
builder.eventListenerFactory(this.eventListenerFactory);
}
if (this.retryOnConnectionFailure != null) {
builder.setRetryOnConnectionFailure$okhttp(this.retryOnConnectionFailure);
}
if (this.followRedirects != null) {
builder.followRedirects(this.followRedirects);
}
if (this.dns != null) {
builder.dns(this.dns);
}
if (this.connectTimeout != null && this.connectTimeUnit != null) {
builder.connectTimeout(this.connectTimeout, this.connectTimeUnit);
}
if (this.callTimeout != null && this.callTimeUnit != null) {
builder.callTimeout(this.callTimeout, this.callTimeUnit);
}
if (this.readTimeout != null && this.readTimeUnit != null) {
builder.readTimeout(this.readTimeout, this.readTimeUnit);
}
if (this.writeTimeout != null && this.writeTimeUnit != null) {
builder.writeTimeout(this.writeTimeout, this.writeTimeUnit);
}
if (this.pingInterval != null) {
builder.setPingInterval$okhttp(this.pingInterval);
}
this.okHttpClient = builder.build();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpResponseProxy.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpResponseProxy.java | package me.chanjar.weixin.common.util.http.okhttp;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import okhttp3.Response;
public class OkHttpResponseProxy implements HttpResponseProxy {
private final Response response;
public OkHttpResponseProxy(Response response) {
this.response = response;
}
@Override
public String getFileName() throws WxErrorException {
String content = this.response.header("Content-disposition");
return HttpResponseProxy.extractFileNameFromContentString(content);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestCustomizeExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author liming1019
* created on 2021/8/10
*/
@Slf4j
public class JoddHttpMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp, String respType, String imgUrl) {
super(requestHttp, respType, imgUrl);
}
@Override
public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
if (this.uploadType.equals("0")) {
request.form("resp_type", this.respType,
"upload_type", this.uploadType,
"media", file);
}
else {
request.form("resp_type", this.respType,
"upload_type", this.uploadType,
"img_url", this.imgUrl);
}
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadCustomizeResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimpleGetRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/4
*/
public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpSimpleGetRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
HttpRequest request = HttpRequest.get(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
return handleResponse(wxType, response.bodyText());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpResponseProxy.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpResponseProxy.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpResponse;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
public class JoddHttpResponseProxy implements HttpResponseProxy {
private final HttpResponse response;
public JoddHttpResponseProxy(HttpResponse httpResponse) {
this.response = httpResponse;
}
@Override
public String getFileName() throws WxErrorException {
String content = response.header("Content-disposition");
return HttpResponseProxy.extractFileNameFromContentString(content);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import jodd.http.upload.ByteArrayUploadable;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.InputStreamData;
import me.chanjar.weixin.common.util.http.MediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
* 文件输入流上传.
*
* @author meiqin.zhou91@gmail.com
* created on 2022/02/15
*/
public class JoddHttpMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMediaInputStreamUploadRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.form("media", new ByteArrayUploadable(this.toByteArray(data.getInputStream()), data.getFilename()));
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
public byte[] toByteArray(InputStream input) throws IOException {
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
return output.toByteArray();
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/5
*/
public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMediaDownloadRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@Override
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? queryParam : '&' + queryParam;
}
HttpRequest request = HttpRequest.get(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String contentType = response.header("Content-Type");
if (contentType != null && contentType.startsWith("application/json")) {
// application/json; encoding=utf-8 下载媒体文件出错
throw new WxErrorException(WxError.fromJson(response.bodyText(), wxType));
}
String fileName = HttpResponseProxy.from(response).getFileName();
if (StringUtils.isBlank(fileName)) {
return null;
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) {
return FileUtils.createTmpFile(inputStream,
baseName,
FilenameUtils.getExtension(fileName),
super.tmpDirFile);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/4
*/
public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpSimplePostRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException {
HttpConnectionProvider provider = requestHttp.getRequestHttpClient();
ProxyInfo proxyInfo = requestHttp.getRequestHttpProxy();
HttpRequest request = HttpRequest.post(uri);
if (proxyInfo != null) {
provider.useProxy(proxyInfo);
}
request.withConnectionProvider(provider);
if (postEntity != null) {
request.contentType("application/json", "utf-8");
request.bodyText(postEntity);
}
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
return this.handleResponse(wxType, response.bodyText());
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/5
*/
public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMediaUploadRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.form("media", file);
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return WxMediaUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMinishopMediaUploadRequestExecutor.java | package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* created on 2017/5/5
*/
@Slf4j
public class JoddHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMinishopMediaUploadRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.form("media", file);
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: {}", responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2Service.java | package me.chanjar.weixin.common.service;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* oauth2 相关接口.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-08-08
*/
public interface WxOAuth2Service {
/**
* <pre>
* 构造oauth2授权的url连接.
* 详情请见: <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html">网页授权</a>
* </pre>
*
* @param redirectUri 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode
* @param scope scope,静默:snsapi_base, 带信息授权:snsapi_userinfo
* @param state state
* @return url
*/
String buildAuthorizationUrl(String redirectUri, String scope, String state);
/**
* <pre>
* 用code换取oauth2的access token.
* 详情请见: <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html">网页授权获取用户基本信息</a>
* </pre>
*
* @param code code
* @return token对象
* @throws WxErrorException .
*/
WxOAuth2AccessToken getAccessToken(String code) throws WxErrorException;
/**
* 用code换取oauth2的access token.
*
* @param appId the appid
* @param appSecret the secret
* @param code code
* @return token对象
* @throws WxErrorException .
*/
WxOAuth2AccessToken getAccessToken(String appId, String appSecret, String code) throws WxErrorException;
/**
* <pre>
* 刷新oauth2的access token.
* </pre>
*
* @param refreshToken 刷新token
* @return 新的token对象
* @throws WxErrorException .
*/
WxOAuth2AccessToken refreshAccessToken(String refreshToken) throws WxErrorException;
/**
* <pre>
* 用oauth2获取用户信息, 当前面引导授权时的scope是snsapi_userinfo的时候才可以.
* </pre>
*
* @param oAuth2AccessToken token对象
* @param lang zh_CN, zh_TW, en
* @return 用户对象
* @throws WxErrorException .
*/
WxOAuth2UserInfo getUserInfo(WxOAuth2AccessToken oAuth2AccessToken, String lang) throws WxErrorException;
/**
* <pre>
* 验证oauth2的access token是否有效.
* </pre>
*
* @param oAuth2AccessToken token对象
* @return 是否有效
*/
boolean validateAccessToken(WxOAuth2AccessToken oAuth2AccessToken);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxImgProcService.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxImgProcService.java | package me.chanjar.weixin.common.service;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.bean.imgproc.WxImgProcAiCropResult;
import me.chanjar.weixin.common.bean.imgproc.WxImgProcQrCodeResult;
import me.chanjar.weixin.common.bean.imgproc.WxImgProcSuperResolutionResult;
import java.io.File;
/**
* 多项图像处理能力相关的API.
* https://developers.weixin.qq.com/doc/offiaccount/Intelligent_Interface/Img_Proc.html
*
* @author Theo Nie
*/
public interface WxImgProcService {
/**
* 二维码/条码识别接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.支持条码、二维码、DataMatrix和PDF417的识别。
* 4.二维码、DataMatrix会返回位置坐标,条码和PDF417暂不返回位置坐标。
*
* @param imgUrl 图片url地址
* @return WxMpImgProcQrCodeResult
* @throws WxErrorException .
*/
WxImgProcQrCodeResult qrCode(String imgUrl) throws WxErrorException;
/**
* 二维码/条码识别接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.支持条码、二维码、DataMatrix和PDF417的识别。
* 4.二维码、DataMatrix会返回位置坐标,条码和PDF417暂不返回位置坐标。
*
* @param imgFile 图片文件对象
* @return WxMpImgProcQrCodeResult
* @throws WxErrorException .
*/
WxImgProcQrCodeResult qrCode(File imgFile) throws WxErrorException;
/**
* 图片高清化接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.目前支持将图片超分辨率高清化2倍,即生成图片分辨率为原图2倍大小
* 返回的media_id有效期为3天,期间可以通过“获取临时素材”接口获取图片二进制
*
* @param imgUrl 图片url地址
* @return WxMpImgProcSuperResolutionResult
* @throws WxErrorException .
*/
WxImgProcSuperResolutionResult superResolution(String imgUrl) throws WxErrorException;
/**
* 图片高清化接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.目前支持将图片超分辨率高清化2倍,即生成图片分辨率为原图2倍大小
* 返回的media_id有效期为3天,期间可以通过“获取临时素材”接口获取图片二进制
*
* @param imgFile 图片文件对象
* @return WxMpImgProcSuperResolutionResult
* @throws WxErrorException .
*/
WxImgProcSuperResolutionResult superResolution(File imgFile) throws WxErrorException;
/**
* 图片智能裁剪接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.该接口默认使用最佳宽高比
* @param imgUrl 图片url地址
* @return WxMpImgProcAiCropResult
* @throws WxErrorException .
*/
WxImgProcAiCropResult aiCrop(String imgUrl) throws WxErrorException;
/**
* 图片智能裁剪接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* @param imgUrl 图片url地址
* @param ratios 宽高比,最多支持5个,请以英文逗号分隔
* @return WxMpImgProcAiCropResult
* @throws WxErrorException .
*/
WxImgProcAiCropResult aiCrop(String imgUrl, String ratios) throws WxErrorException;
/**
* 图片智能裁剪接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* 3.该接口默认使用最佳宽高比
* @param imgFile 图片文件对象
* @return WxMpImgProcAiCropResult
* @throws WxErrorException .
*/
WxImgProcAiCropResult aiCrop(File imgFile) throws WxErrorException;
/**
* 图片智能裁剪接口
* 说明:
* 1.图片支持使用img参数实时上传,也支持使用img_url参数传送图片地址,由微信后台下载图片进行识别
* 2.文件大小限制:小于2M
* @param imgFile 图片文件对象
* @param ratios 宽高比,最多支持5个,请以英文逗号分隔
* @return WxMpImgProcAiCropResult
* @throws WxErrorException .
*/
WxImgProcAiCropResult aiCrop(File imgFile, String ratios) throws WxErrorException;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java | package me.chanjar.weixin.common.service;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.bean.ocr.WxOcrBankCardResult;
import me.chanjar.weixin.common.bean.ocr.WxOcrBizLicenseResult;
import me.chanjar.weixin.common.bean.ocr.WxOcrCommResult;
import me.chanjar.weixin.common.bean.ocr.WxOcrDrivingLicenseResult;
import me.chanjar.weixin.common.bean.ocr.WxOcrDrivingResult;
import me.chanjar.weixin.common.bean.ocr.WxOcrIdCardResult;
import java.io.File;
/**
* 基于小程序或 H5 的身份证、银行卡、行驶证 OCR 识别.
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712284rHWMX
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2019-06-22
*/
public interface WxOcrService {
/**
* 身份证OCR识别接口.
*
* @param imgUrl 图片url地址
* @return WxMpOcrIdCardResult
* @throws WxErrorException .
*/
WxOcrIdCardResult idCard(String imgUrl) throws WxErrorException;
/**
* 身份证OCR识别接口.
*
* @param imgFile 图片文件对象
* @return WxMpOcrIdCardResult
* @throws WxErrorException .
*/
WxOcrIdCardResult idCard(File imgFile) throws WxErrorException;
/**
* 银行卡OCR识别接口
* 文件大小限制:小于2M
* @param imgUrl 图片url地址
* @return WxMpOcrBankCardResult
* @throws WxErrorException .
*/
WxOcrBankCardResult bankCard(String imgUrl) throws WxErrorException;
/**
* 银行卡OCR识别接口
* 文件大小限制:小于2M
* @param imgFile 图片文件对象
* @return WxMpOcrBankCardResult
* @throws WxErrorException .
*/
WxOcrBankCardResult bankCard(File imgFile) throws WxErrorException;
/**
* 行驶证OCR识别接口
* 文件大小限制:小于2M
* @param imgUrl 图片url地址
* @return WxMpOcrDrivingResult
* @throws WxErrorException .
*/
WxOcrDrivingResult driving(String imgUrl) throws WxErrorException;
/**
* 行驶证OCR识别接口
* 文件大小限制:小于2M
* @param imgFile 图片文件对象
* @return WxMpOcrDrivingResult
* @throws WxErrorException .
*/
WxOcrDrivingResult driving(File imgFile) throws WxErrorException;
/**
* 驾驶证OCR识别接口
* 文件大小限制:小于2M
* @param imgUrl 图片url地址
* @return WxMpOcrDrivingLicenseResult
* @throws WxErrorException .
*/
WxOcrDrivingLicenseResult drivingLicense(String imgUrl) throws WxErrorException;
/**
* 驾驶证OCR识别接口
* 文件大小限制:小于2M
* @param imgFile 图片文件对象
* @return WxMpOcrDrivingLicenseResult
* @throws WxErrorException .
*/
WxOcrDrivingLicenseResult drivingLicense(File imgFile) throws WxErrorException;
/**
* 营业执照OCR识别接口
* 文件大小限制:小于2M
* @param imgUrl 图片url地址
* @return WxMpOcrBizLicenseResult
* @throws WxErrorException .
*/
WxOcrBizLicenseResult bizLicense(String imgUrl) throws WxErrorException;
/**
* 营业执照OCR识别接口
* 文件大小限制:小于2M
* @param imgFile 图片文件对象
* @return WxMpOcrBizLicenseResult
* @throws WxErrorException .
*/
WxOcrBizLicenseResult bizLicense(File imgFile) throws WxErrorException;
/**
* 通用印刷体OCR识别接口
* 文件大小限制:小于2M
* 适用于屏幕截图、印刷体照片等场景
* @param imgUrl 图片url地址
* @return WxMpOcrCommResult
* @throws WxErrorException .
*/
WxOcrCommResult comm(String imgUrl) throws WxErrorException;
/**
* 通用印刷体OCR识别接口
* 文件大小限制:小于2M
* 适用于屏幕截图、印刷体照片等场景
* @param imgFile 图片文件对象
* @return WxMpOcrCommResult
* @throws WxErrorException .
*/
WxOcrCommResult comm(File imgFile) throws WxErrorException;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2ServiceDecorator.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOAuth2ServiceDecorator.java | package me.chanjar.weixin.common.service;
import lombok.AllArgsConstructor;
import lombok.experimental.Delegate;
/**
* 微信 oauth2服务 装饰器
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
*/
@AllArgsConstructor
public class WxOAuth2ServiceDecorator implements WxOAuth2Service {
@Delegate
private final WxOAuth2Service wxOAuth2Service;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxService.java | package me.chanjar.weixin.common.service;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.bean.ToJson;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* 微信服务接口.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-04-25
*/
public interface WxService {
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
*
* @param queryParam 参数
* @param url 请求接口地址
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String get(String url, String queryParam) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
*
* @param postData 请求参数json值
* @param url 请求接口地址
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String post(String url, String postData) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
*
* @param url 请求接口地址
* @param obj 请求对象
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String post(String url, Object obj) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
*
* @param url 请求接口地址
* @param jsonObject 请求对象
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String post(String url, JsonObject jsonObject) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
*
* @param url 请求接口地址
* @param obj 请求对象,实现了ToJson接口
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String post(String url, ToJson obj) throws WxErrorException;
/**
* 当本Service没有实现某个上传API的时候,可以用这个,针对所有微信API中的POST文件上传请求
*
* @param url 请求接口地址
* @param param 文件上传对象
* @return 接口响应字符串
* @throws WxErrorException 异常
*/
String upload(String url, CommonUploadParam param) throws WxErrorException;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxCpErrorMsgEnum.java | package me.chanjar.weixin.common.error;
import com.google.common.collect.Maps;
import lombok.Getter;
import java.util.Map;
/**
* <pre>
* 企业微信全局错误码.
* 参考文档:<a href="https://work.weixin.qq.com/api/doc/90000/90139/90313">企业微信全局错误码</a>
* Created by Binary Wang on 2018/5/13.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Getter
public enum WxCpErrorMsgEnum {
/**
* 系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次.
*/
CODE_1(-1, "系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次。"),
/**
* 请求成功;接口调用成功.
*/
CODE_0(0, "请求成功;接口调用成功"),
/**
* 不合法的secret参数;secret在应用详情/通讯录管理助手可查看.
*/
CODE_40001(40001, "不合法的secret参数;secret在应用详情/通讯录管理助手可查看"),
/**
* 无效的UserID.
*/
CODE_40003(40003, "无效的UserID"),
/**
* 不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制.
*/
CODE_40004(40004, "不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制"),
/**
* 不合法的type参数;合法的type取值,参考:上传临时素材.
*/
CODE_40005(40005, "不合法的type参数;合法的type取值,参考:上传临时素材"),
/**
* 不合法的文件大小;系统文件要求,参考:上传的媒体文件限制.
*/
CODE_40006(40006, "不合法的文件大小;系统文件要求,参考:上传的媒体文件限制"),
/**
* 不合法的media_id参数.
*/
CODE_40007(40007, "不合法的media_id参数"),
/**
* 不合法的msgtype参数;合法的msgtype取值,参考:消息类型.
*/
CODE_40008(40008, "不合法的msgtype参数;合法的msgtype取值,参考:消息类型"),
/**
* 上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制.
*/
CODE_40009(40009, "上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制"),
/**
* 上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制.
*/
CODE_40011(40011, "上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制"),
/**
* 不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看.
*/
CODE_40013(40013, "不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看"),
/**
* 不合法的access_token.
*/
CODE_40014(40014, "不合法的access_token"),
/**
* 不合法的按钮个数;菜单按钮1-3个.
*/
CODE_40016(40016, "不合法的按钮个数;菜单按钮1-3个"),
/**
* 不合法的按钮类型;支持的类型,参考:按钮类型.
*/
CODE_40017(40017, "不合法的按钮类型;支持的类型,参考:按钮类型"),
/**
* 不合法的按钮名字长度;长度应不超过16个字节.
*/
CODE_40018(40018, "不合法的按钮名字长度;长度应不超过16个字节"),
/**
* 不合法的按钮KEY长度;长度应不超过128字节.
*/
CODE_40019(40019, "不合法的按钮KEY长度;长度应不超过128字节"),
/**
* 不合法的按钮URL长度;长度应不超过1024字节.
*/
CODE_40020(40020, "不合法的按钮URL长度;长度应不超过1024字节"),
/**
* 不合法的子菜单级数;只能包含一级菜单和二级菜单.
*/
CODE_40022(40022, "不合法的子菜单级数;只能包含一级菜单和二级菜单"),
/**
* 不合法的子菜单按钮个数;子菜单按钮1-5个.
*/
CODE_40023(40023, "不合法的子菜单按钮个数;子菜单按钮1-5个"),
/**
* 不合法的子菜单按钮类型;支持的类型,参考:按钮类型.
*/
CODE_40024(40024, "不合法的子菜单按钮类型;支持的类型,参考:按钮类型"),
/**
* 不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型.
*/
CODE_40025(40025, "不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型"),
/**
* 不合法的子菜单按钮KEY长度;长度应不超过60个字节.
*/
CODE_40026(40026, "不合法的子菜单按钮KEY长度;长度应不超过60个字节"),
/**
* 不合法的子菜单按钮URL长度;长度应不超过1024字节.
*/
CODE_40027(40027, "不合法的子菜单按钮URL长度;长度应不超过1024字节"),
/**
* 不合法的oauth_code.
*/
CODE_40029(40029, "不合法的oauth_code"),
/**
* 不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中.
*/
CODE_40031(40031, "不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中"),
/**
* 不合法的UserID列表长度.
*/
CODE_40032(40032, "不合法的UserID列表长度"),
/**
* 不合法的请求字符;不能包含\\uxxxx格式的字符.
*/
CODE_40033(40033, "不合法的请求字符;不能包含\\uxxxx格式的字符"),
/**
* 不合法的参数.
*/
CODE_40035(40035, "不合法的参数"),
/**
* chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天.
*/
CODE_40050(40050, "chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天"),
/**
* 不合法的子菜单url域名.
*/
CODE_40054(40054, "不合法的子菜单url域名"),
/**
* 不合法的菜单url域名.
*/
CODE_40055(40055, "不合法的菜单url域名"),
/**
* 不合法的agentid.
*/
CODE_40056(40056, "不合法的agentid"),
/**
* 不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现.
*/
CODE_40057(40057, "不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现"),
/**
* 不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明.
*/
CODE_40058(40058, "不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明"),
/**
* 不合法的上报地理位置标志位;开关标志位只能填 0 或者 1.
*/
CODE_40059(40059, "不合法的上报地理位置标志位;开关标志位只能填 0 或者 1"),
/**
* 参数为空.
*/
CODE_40063(40063, "参数为空"),
/**
* 不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中.
*/
CODE_40066(40066, "不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中"),
/**
* 不合法的标签ID;标签ID未指定,或者指定的标签ID不存在.
*/
CODE_40068(40068, "不合法的标签ID;标签ID未指定,或者指定的标签ID不存在"),
/**
* 指定的标签范围结点全部无效.
*/
CODE_40070(40070, "指定的标签范围结点全部无效"),
/**
* 不合法的标签名字;标签名字已经存在.
*/
CODE_40071(40071, "不合法的标签名字;标签名字已经存在"),
/**
* 不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母).
*/
CODE_40072(40072, "不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母)"),
/**
* 不合法的openid;openid不存在,需确认获取来源.
*/
CODE_40073(40073, "不合法的openid;openid不存在,需确认获取来源"),
/**
* news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews.
*/
CODE_40074(40074, "news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews"),
/**
* 不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码.
*/
CODE_40077(40077, "不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码"),
/**
* 不合法的auth_code参数;需确认获取来源,并且只能消费一次.
*/
CODE_40078(40078, "不合法的auth_code参数;需确认获取来源,并且只能消费一次"),
/**
* 不合法的suite_secret;套件secret可在第三方管理端套件详情查看.
*/
CODE_40080(40080, "不合法的suite_secret;套件secret可在第三方管理端套件详情查看"),
/**
* 不合法的suite_token.
*/
CODE_40082(40082, "不合法的suite_token"),
/**
* 不合法的suite_id;suite_id不存在.
*/
CODE_40083(40083, "不合法的suite_id;suite_id不存在"),
/**
* 不合法的permanent_code参数.
*/
CODE_40084(40084, "不合法的permanent_code参数"),
/**
* 不合法的的suite_ticket参数;suite_ticket不存在或者已失效.
*/
CODE_40085(40085, "不合法的的suite_ticket参数;suite_ticket不存在或者已失效"),
/**
* 不合法的第三方应用appid;至少有一个不存在应用id.
*/
CODE_40086(40086, "不合法的第三方应用appid;至少有一个不存在应用id"),
/**
* jobid不存在;请检查 jobid 来源.
*/
CODE_40088(40088, "jobid不存在;请检查 jobid 来源"),
/**
* 批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况.
*/
CODE_40089(40089, "批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况"),
/**
* secret不合法;可能用了别的企业的secret.
*/
CODE_40091(40091, "secret不合法;可能用了别的企业的secret"),
/**
* 导入文件存在不合法的内容.
*/
CODE_40092(40092, "导入文件存在不合法的内容"),
/**
* 不合法的jsapi_ticket参数;ticket已失效,或者拼写错误.
*/
CODE_40093(40093, "不合法的jsapi_ticket参数;ticket已失效,或者拼写错误"),
/**
* 不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头).
*/
CODE_40094(40094, "不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头)"),
/**
* 不合法的外部联系人userid
*/
CODE_40096(40096,"不合法的外部联系人userid"),
/**
* 缺少access_token参数.
*/
CODE_41001(41001, "缺少access_token参数"),
/**
* 缺少corpid参数.
*/
CODE_41002(41002, "缺少corpid参数"),
/**
* 缺少secret参数.
*/
CODE_41004(41004, "缺少secret参数"),
/**
* 缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递.
*/
CODE_41006(41006, "缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递"),
/**
* 缺少auth code参数.
*/
CODE_41008(41008, "缺少auth code参数"),
/**
* 缺少userid参数.
*/
CODE_41009(41009, "缺少userid参数"),
/**
* 缺少url参数.
*/
CODE_41010(41010, "缺少url参数"),
/**
* 缺少agentid参数.
*/
CODE_41011(41011, "缺少agentid参数"),
/**
* 缺少 description 参数;发送文本卡片消息接口,description 是必填字段.
*/
CODE_41033(41033, "缺少 description 参数;发送文本卡片消息接口,description 是必填字段"),
/**
* 缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递.
*/
CODE_41016(41016, "缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递。"),
/**
* 缺少 department 参数.
*/
CODE_41019(41019, "缺少 department 参数"),
/**
* 缺少tagid参数.
*/
CODE_41017(41017, "缺少tagid参数"),
/**
* 缺少suite_id参数.
*/
CODE_41021(41021, "缺少suite_id参数"),
/**
* 缺少suite_access_token参数.
*/
CODE_41022(41022, "缺少suite_access_token参数"),
/**
* 缺少suite_ticket参数.
*/
CODE_41023(41023, "缺少suite_ticket参数"),
/**
* 缺少secret参数.
*/
CODE_41024(41024, "缺少secret参数"),
/**
* 缺少permanent_code参数.
*/
CODE_41025(41025, "缺少permanent_code参数"),
/**
* access_token已过期;access_token有时效性,需要重新获取一次.
*/
CODE_42001(42001, "access_token已过期;access_token有时效性,需要重新获取一次"),
/**
* pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次.
*/
CODE_42007(42007, "pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次"),
/**
* suite_access_token已过期;suite_access_token有时效性,需要重新获取一次.
*/
CODE_42009(42009, "suite_access_token已过期;suite_access_token有时效性,需要重新获取一次"),
/**
* 指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid.
*/
CODE_43004(43004, "指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid"),
/**
* 多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确.
*/
CODE_44001(44001, "多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确。"),
/**
* 文本消息content参数为空;发文本消息content为必填参数,且不能为空.
*/
CODE_44004(44004, "文本消息content参数为空;发文本消息content为必填参数,且不能为空"),
/**
* 多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M.
*/
CODE_45001(45001, "多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M"),
/**
* 消息内容大小超过限制.
*/
CODE_45002(45002, "消息内容大小超过限制"),
/**
* 应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符.
*/
CODE_45004(45004, "应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符"),
/**
* 语音播放时间超过限制;语音播放时长不能超过60秒.
*/
CODE_45007(45007, "语音播放时间超过限制;语音播放时长不能超过60秒"),
/**
* 图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条.
*/
CODE_45008(45008, "图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条"),
/**
* 接口调用超过限制.
*/
CODE_45009(45009, "接口调用超过限制"),
/**
* 应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符.
*/
CODE_45022(45022, "应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符"),
/**
* 帐号数量超过上限.
*/
CODE_45024(45024, "帐号数量超过上限"),
/**
* 触发删除用户数的保护;限制参考:全量覆盖成员.
*/
CODE_45026(45026, "触发删除用户数的保护;限制参考:全量覆盖成员"),
/**
* 图文消息author参数长度超过限制;最长64个字节.
*/
CODE_45032(45032, "图文消息author参数长度超过限制;最长64个字节"),
/**
* 接口并发调用超过限制.
*/
CODE_45033(45033, "接口并发调用超过限制"),
/**
* 菜单未设置;菜单需发布后才能获取到数据.
*/
CODE_46003(46003, "菜单未设置;菜单需发布后才能获取到数据"),
/**
* 指定的用户不存在;需要确认指定的用户存在于通讯录中.
*/
CODE_46004(46004, "指定的用户不存在;需要确认指定的用户存在于通讯录中"),
/**
* API接口无权限调用.
*/
CODE_48002(48002, "API接口无权限调用"),
/**
* 不合法的suite_id;确认suite_access_token由指定的suite_id生成.
*/
CODE_48003(48003, "不合法的suite_id;确认suite_access_token由指定的suite_id生成"),
/**
* 授权关系无效;可能是无授权或授权已被取消.
*/
CODE_48004(48004, "授权关系无效;可能是无授权或授权已被取消"),
/**
* API接口已废弃;接口已不再支持,建议改用新接口或者新方案.
*/
CODE_48005(48005, "API接口已废弃;接口已不再支持,建议改用新接口或者新方案"),
/**
* redirect_url未登记可信域名.
*/
CODE_50001(50001, "redirect_url未登记可信域名"),
/**
* 成员不在权限范围;请检查应用或管理组的权限范围.
*/
CODE_50002(50002, "成员不在权限范围;请检查应用或管理组的权限范围"),
/**
* 应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用.
*/
CODE_50003(50003, "应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用"),
/**
* 部门长度不符合限制;部门名称不能为空且长度不能超过32个字.
*/
CODE_60001(60001, "部门长度不符合限制;部门名称不能为空且长度不能超过32个字"),
/**
* 部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中.
*/
CODE_60003(60003, "部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中"),
/**
* 父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中.
*/
CODE_60004(60004, "父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中"),
/**
* 部门下存在成员;不允许删除有成员的部门.
*/
CODE_60005(60005, "部门下存在成员;不允许删除有成员的部门"),
/**
* 部门下存在子部门;不允许删除有子部门的部门.
*/
CODE_60006(60006, "部门下存在子部门;不允许删除有子部门的部门"),
/**
* 不允许删除根部门.
*/
CODE_60007(60007, "不允许删除根部门"),
/**
* 部门已存在;部门ID或者部门名称已存在.
*/
CODE_60008(60008, "部门已存在;部门ID或者部门名称已存在"),
/**
* 部门名称含有非法字符;不能含有 \\:?*“< >| 等字符.
*/
CODE_60009(60009, "部门名称含有非法字符;不能含有 \\ :?*“< >| 等字符"),
/**
* 部门存在循环关系.
*/
CODE_60010(60010, "部门存在循环关系"),
/**
* 指定的成员/部门/标签参数无权限.
*/
CODE_60011(60011, "指定的成员/部门/标签参数无权限"),
/**
* 不允许删除默认应用;默认应用的id为0.
*/
CODE_60012(60012, "不允许删除默认应用;默认应用的id为0"),
/**
* 访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表.
*/
CODE_60020(60020, "访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表"),
/**
* 不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL.
*/
CODE_60028(60028, "不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL"),
/**
* UserID已存在.
*/
CODE_60102(60102, "UserID已存在"),
/**
* 手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号.
*/
CODE_60103(60103, "手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号"),
/**
* 手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录.
*/
CODE_60104(60104, "手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录。"),
/**
* 邮箱不合法;长度不超过64位,且为有效的email格式.
*/
CODE_60105(60105, "邮箱不合法;长度不超过64位,且为有效的email格式"),
/**
* 邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录.
*/
CODE_60106(60106, "邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录。"),
/**
* 微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“.
*/
CODE_60107(60107, "微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“"),
/**
* 用户所属部门数量超过限制;用户同时归属部门不超过20个.
*/
CODE_60110(60110, "用户所属部门数量超过限制;用户同时归属部门不超过20个"),
/**
* UserID不存在;UserID参数为空,或者不存在通讯录中.
*/
CODE_60111(60111, "UserID不存在;UserID参数为空,或者不存在通讯录中"),
/**
* 成员name参数不合法;不能为空,且不能超过64字符.
*/
CODE_60112(60112, "成员name参数不合法;不能为空,且不能超过64字符"),
/**
* 无效的部门id;部门不存在通讯录中.
*/
CODE_60123(60123, "无效的部门id;部门不存在通讯录中"),
/**
* 无效的父部门id;父部门不存在通讯录中.
*/
CODE_60124(60124, "无效的父部门id;父部门不存在通讯录中"),
/**
* 非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符.
*/
CODE_60125(60125, "非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符"),
/**
* 缺少department参数.
*/
CODE_60127(60127, "缺少department参数"),
/**
* 成员手机和邮箱都为空;成员手机和邮箱至少有个非空.
*/
CODE_60129(60129, "成员手机和邮箱都为空;成员手机和邮箱至少有个非空"),
/**
* 发票已被其他公众号锁定.
*/
CODE_72023(72023, "发票已被其他公众号锁定"),
/**
* 发票状态错误;reimburse_status状态错误,参考:更新发票状态.
*/
CODE_72024(72024, "发票状态错误;reimburse_status状态错误,参考:更新发票状态"),
/**
* 存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态.
*/
CODE_72037(72037, "存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态"),
/**
* 可信域名不正确,或者无ICP备案.
*/
CODE_80001(80001, "可信域名不正确,或者无ICP备案"),
/**
* 部门下的结点数超过限制(3W).
*/
CODE_81001(81001, "部门下的结点数超过限制(3W)"),
/**
* 部门最多15层.
*/
CODE_81002(81002, "部门最多15层"),
/**
* 无权限操作标签.
*/
CODE_81011(81011, "无权限操作标签"),
/**
* UserID、部门ID、标签ID全部非法或无权限.
*/
CODE_81013(81013, "UserID、部门ID、标签ID全部非法或无权限"),
/**
* 标签添加成员,单次添加user或party过多.
*/
CODE_81014(81014, "标签添加成员,单次添加user或party过多"),
/**
* 指定的成员/部门/标签全部无效.
*/
CODE_82001(82001, "指定的成员/部门/标签全部无效"),
/**
* 不合法的PartyID列表长度;发消息,单次不能超过100个部门.
*/
CODE_82002(82002, "不合法的PartyID列表长度;发消息,单次不能超过100个部门"),
/**
* 不合法的TagID列表长度;发消息,单次不能超过100个标签.
*/
CODE_82003(82003, "不合法的TagID列表长度;发消息,单次不能超过100个标签"),
/**
* 成员票据过期.
*/
CODE_84014(84014, "成员票据过期"),
/**
* 成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息.
*/
CODE_84015(84015, "成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息"),
/**
* 缺少templateid参数.
*/
CODE_84019(84019, "缺少templateid参数"),
/**
* templateid不存在;确认参数是否有带,并且已创建.
*/
CODE_84020(84020, "templateid不存在;确认参数是否有带,并且已创建"),
/**
* 缺少register_code参数.
*/
CODE_84021(84021, "缺少register_code参数"),
/**
* 无效的register_code参数.
*/
CODE_84022(84022, "无效的register_code参数"),
/**
* 不允许调用设置通讯录同步完成接口.
*/
CODE_84023(84023, "不允许调用设置通讯录同步完成接口"),
/**
* 无注册信息.
*/
CODE_84024(84024, "无注册信息"),
/**
* 不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节.
*/
CODE_84025(84025, "不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节"),
/**
* 缺少caller参数.
*/
CODE_84052(84052, "缺少caller参数"),
/**
* 缺少callee参数.
*/
CODE_84053(84053, "缺少callee参数"),
/**
* 缺少auth_corpid参数.
*/
CODE_84054(84054, "缺少auth_corpid参数"),
/**
* 超过拨打公费电话频率。排查方法:同一个客服5秒内只能调用api拨打一次公费电话
*/
CODE_84055(84055, "超过拨打公费电话频率。排查方法:同一个客服5秒内只能调用api拨打一次公费电话"),
/**
* 被拨打用户安装应用时未授权拨打公费电话权限.
*/
CODE_84056(84056, "被拨打用户安装应用时未授权拨打公费电话权限"),
/**
* 公费电话余额不足.
*/
CODE_84057(84057, "公费电话余额不足"),
/**
* caller
*/
CODE_84058(84058, "caller 呼叫号码不支持"),
/**
* 号码非法.
*/
CODE_84059(84059, "号码非法"),
/**
* callee
*/
CODE_84060(84060, "callee 呼叫号码不支持"),
/**
* 不存在外部联系人的关系.
*/
CODE_84061(84061, "不存在外部联系人的关系"),
/**
* 未开启公费电话应用.
*/
CODE_84062(84062, "未开启公费电话应用"),
/**
* caller不存在.
*/
CODE_84063(84063, "caller不存在"),
/**
* callee不存在.
*/
CODE_84064(84064, "callee不存在"),
/**
* caller跟callee电话号码一致。排查方法:不允许自己拨打给自己
*/
CODE_84065(84065, "caller跟callee电话号码一致。排查方法:不允许自己拨打给自己"),
/**
* 服务商拨打次数超过限制。排查方法:单个企业管理员,在一天(以上午10
*/
CODE_84066(84066, "服务商拨打次数超过限制。排查方法:单个企业管理员,在一天(以上午10:00为起始时间)内,对应单个服务商,只能被呼叫【4】次。"),
/**
* 管理员收到的服务商公费电话个数超过限制。排查方法:单个企业管理员,在一天(以上午10
*/
CODE_84067(84067, "管理员收到的服务商公费电话个数超过限制。排查方法:单个企业管理员,在一天(以上午10:00为起始时间)内,一共只能被【3】个服务商成功呼叫。"),
/**
* 拨打方被限制拨打公费电话.
*/
CODE_84069(84069, "拨打方被限制拨打公费电话"),
/**
* 不支持的电话号码。排查方法:拨打方或者被拨打方电话号码不支持
*/
CODE_84070(84070, "不支持的电话号码。排查方法:拨打方或者被拨打方电话号码不支持"),
/**
* 不合法的外部联系人授权码。排查方法:非法或者已经消费过
*/
CODE_84071(84071, "不合法的外部联系人授权码。排查方法:非法或者已经消费过"),
/**
* 应用未配置客服.
*/
CODE_84072(84072, "应用未配置客服"),
/**
* 客服userid不在应用配置的客服列表中.
*/
CODE_84073(84073, "客服userid不在应用配置的客服列表中"),
/**
* 没有外部联系人权限.
*/
CODE_84074(84074, "没有外部联系人权限"),
/**
* 不合法或过期的authcode.
*/
CODE_84075(84075, "不合法或过期的authcode"),
/**
* 缺失authcode.
*/
CODE_84076(84076, "缺失authcode"),
/**
* 订单价格过高,无法受理.
*/
CODE_84077(84077, "订单价格过高,无法受理"),
/**
* 购买人数不正确.
*/
CODE_84078(84078, "购买人数不正确"),
/**
* 价格策略不存在.
*/
CODE_84079(84079, "价格策略不存在"),
/**
* 订单不存在.
*/
CODE_84080(84080, "订单不存在"),
/**
* 存在未支付订单.
*/
CODE_84081(84081, "存在未支付订单"),
/**
* 存在申请退款中的订单.
*/
CODE_84082(84082, "存在申请退款中的订单"),
/**
* 非服务人员.
*/
CODE_84083(84083, "非服务人员"),
/**
* 非跟进用户.
*/
CODE_84084(84084, "非跟进用户"),
/**
* 应用已下架.
*/
CODE_84085(84085, "应用已下架"),
/**
* 订单人数超过可购买最大人数.
*/
CODE_84086(84086, "订单人数超过可购买最大人数"),
/**
* 打开订单支付前禁止关闭订单.
*/
CODE_84087(84087, "打开订单支付前禁止关闭订单"),
/**
* 禁止关闭已支付的订单.
*/
CODE_84088(84088, "禁止关闭已支付的订单"),
/**
* 订单已支付.
*/
CODE_84089(84089, "订单已支付"),
/**
* 缺失user_ticket.
*/
CODE_84090(84090, "缺失user_ticket"),
/**
* 订单价格不可低于下限.
*/
CODE_84091(84091, "订单价格不可低于下限"),
/**
* 无法发起代下单操作.
*/
CODE_84092(84092, "无法发起代下单操作"),
/**
* 代理关系已占用,无法代下单.
*/
CODE_84093(84093, "代理关系已占用,无法代下单"),
/**
* 该应用未配置代理分润规则,请先联系应用服务商处理.
*/
CODE_84094(84094, "该应用未配置代理分润规则,请先联系应用服务商处理"),
/**
* 免费试用版,无法扩容.
*/
CODE_84095(84095, "免费试用版,无法扩容"),
/**
* 免费试用版,无法续期.
*/
CODE_84096(84096, "免费试用版,无法续期"),
/**
* 当前企业有未处理订单.
*/
CODE_84097(84097, "当前企业有未处理订单"),
/**
* 固定总量,无法扩容.
*/
CODE_84098(84098, "固定总量,无法扩容"),
/**
* 非购买状态,无法扩容.
*/
CODE_84099(84099, "非购买状态,无法扩容"),
/**
* 未购买过此应用,无法续期.
*/
CODE_84100(84100, "未购买过此应用,无法续期"),
/**
* 企业已试用付费版本,无法全新购买.
*/
CODE_84101(84101, "企业已试用付费版本,无法全新购买"),
/**
* 企业当前应用状态已过期,无法扩容.
*/
CODE_84102(84102, "企业当前应用状态已过期,无法扩容"),
/**
* 仅可修改未支付订单.
*/
CODE_84103(84103, "仅可修改未支付订单"),
/**
* 订单已支付,无法修改.
*/
CODE_84104(84104, "订单已支付,无法修改"),
/**
* 订单已被取消,无法修改.
*/
CODE_84105(84105, "订单已被取消,无法修改"),
/**
* 企业含有该应用的待支付订单,无法代下单.
*/
CODE_84106(84106, "企业含有该应用的待支付订单,无法代下单"),
/**
* 企业含有该应用的退款中订单,无法代下单.
*/
CODE_84107(84107, "企业含有该应用的退款中订单,无法代下单"),
/**
* 企业含有该应用的待生效订单,无法代下单.
*/
CODE_84108(84108, "企业含有该应用的待生效订单,无法代下单"),
/**
* 订单定价不能未0.
*/
CODE_84109(84109, "订单定价不能未0"),
/**
* 新安装应用不在试用状态,无法升级为付费版.
*/
CODE_84110(84110, "新安装应用不在试用状态,无法升级为付费版"),
/**
* 无足够可用优惠券.
*/
CODE_84111(84111, "无足够可用优惠券"),
/**
* 无法关闭未支付订单.
*/
CODE_84112(84112, "无法关闭未支付订单"),
/**
* 无付费信息.
*/
CODE_84113(84113, "无付费信息"),
/**
* 虚拟版本不支持下单.
*/
CODE_84114(84114, "虚拟版本不支持下单"),
/**
* 虚拟版本不支持扩容.
*/
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | true |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMaErrorMsgEnum.java | package me.chanjar.weixin.common.error;
import com.google.common.collect.Maps;
import lombok.Getter;
import java.util.Map;
/**
* 微信小程序错误码
*
* @author <a href="https://github.com/biggates">biggates</a>
*/
@Getter
public enum WxMaErrorMsgEnum {
/**
* <pre>
* 获取 access_token 时 AppSecret 错误,
* 或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的小程序调用接口
* 对应操作:<code>sendCustomerMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* </pre>
*/
CODE_40001(40001, "access_token 无效或 AppSecret 错误"),
/**
* <pre>
* 不合法的凭证类型
* 对应操作:<code>sendCustomerMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* </pre>
*/
CODE_40002(40002, "不合法的凭证类型"),
/**
* <pre>
* touser不是正确的openid.
* 对应操作:<code>sendCustomerMessage</code>, <code>sendUniformMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* </pre>
*/
CODE_40003(40003, "openid 不正确"),
/**
* <pre>
* 无效媒体文件类型
* 对应操作:<code>uploadTempMedia</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/uploadTempMedia.html
* </pre>
*/
CODE_40004(40004, "无效媒体文件类型"),
/**
* <pre>
* 无效媒体文件 ID.
* 对应操作:<code>getTempMedia</code>
* 对应地址:
* GET https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/getTempMedia.html
* </pre>
*/
CODE_40007(40007, "无效媒体文件 ID"),
/**
* <pre>
* appid不正确,或者不符合绑定关系要求.
* 对应操作:<code>sendUniformMessage</code>
* 对应地址:
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuota.html
* </pre>
*/
CODE_40013(40013, "appid不正确/不合法(避免异常字符,注意大小写),或者不符合绑定关系要求"),
/**
* <pre>
* template_id 不正确.
* 对应操作:<code>sendUniformMessage</code>, <code>sendTemplateMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html
* </pre>
*/
CODE_40037(40037, "template_id 不正确"),
/**
* <pre>
* form_id不正确,或者过期.
* 对应操作:<code>sendUniformMessage</code>, <code>sendTemplateMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html
* </pre>
*/
CODE_41028(41028, "form_id 不正确,或者过期"),
/**
* <pre>
* code 或 template_id 不正确.
* 对应操作:<code>code2Session</code>, <code>sendUniformMessage</code>, <code>sendTemplateMessage</code>
* 对应地址:
* GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html
* </pre>
*/
CODE_41029(41029, "请求的参数不正确"),
/**
* <pre>
* form_id 已被使用,或者所传page页面不存在,或者小程序没有发布
* 对应操作:<code>sendUniformMessage</coce>, <code>getWXACodeUnlimit</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html
* </pre>
*/
CODE_41030(41030, "请求的参数不正确"),
/**
* <pre>
* 调用分钟频率受限.
* 对应操作:<code>getWXACodeUnlimit</code>, <code>sendUniformMessage</code>, <code>sendTemplateMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html
* </pre>
*/
CODE_45009(45009, "调用分钟频率受限"),
/**
* <pre>
* 频率限制,每个用户每分钟100次.
* 对应操作:<code>code2Session</code>
* 对应地址:
* GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html
* </pre>
*/
CODE_45011(45011, "频率限制,每个用户每分钟100次"),
/**
* <pre>
* 回复时间超过限制.
* 对应操作:<code>sendCustomerMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* </pre>
*/
CODE_45015(45015, "回复时间超过限制"),
/**
* <pre>
* 接口调用超过限额, 或生成码个数总和到达最大个数限制.
* 对应操作:<code>createWXAQRCode</code>, <code>sendTemplateMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACode.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html
* </pre>
*/
CODE_45029(45029, "接口调用超过限额"),
/**
* <pre>
* 客服接口下行条数超过上限.
* 对应操作:<code>sendCustomerMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* </pre>
*/
CODE_45047(45047, "客服接口下行条数超过上限"),
/**
* <pre>
* command字段取值不对
* 对应操作:<code>customerTyping</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html
* </pre>
*/
CODE_45072(45072, "command字段取值不对"),
/**
* <pre>
* 下发输入状态,需要之前30秒内跟用户有过消息交互.
* 对应操作:<code>customerTyping</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html
*/
CODE_45080(45080, "下发输入状态,需要之前30秒内跟用户有过消息交互"),
/**
* <pre>
* 已经在输入状态,不可重复下发.
* 对应操作:<code>customerTyping</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html
* </pre>
*/
CODE_45081(45081, "已经在输入状态,不可重复下发"),
/**
* <pre>
* API 功能未授权,请确认小程序已获得该接口.
* 对应操作:<code>sendCustomerMessage</code>
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
* </pre>
*/
CODE_48001(48001, "API 功能未授权"),
/**
* <pre>
* 内容含有违法违规内容.
* 对应操作:<code>imgSecCheck</code>, <code>msgSecCheck</code>
* 对应地址:
* POST https://api.weixin.qq.com/wxa/img_sec_check?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/imgSecCheck.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/msgSecCheck.html
* </pre>
*/
CODE_87014(87014, "内容含有违法违规内容"),
/**
* 系统繁忙,此时请开发者稍候再试.
*/
CODE_MINUS_1(-1, "系统繁忙,此时请开发者稍候再试"),
/**
* code 无效.
*/
CODE_40029(40029, "code 无效"),
/**
* access_token 过期.
*/
CODE_42001(42001, "access_token 过期"),
/**
* post 数据为空.
*/
CODE_44002(44002, "post 数据为空"),
/**
* post 数据中参数缺失.
*/
CODE_47001(47001, "post 数据中参数缺失"),
/**
* 参数 activity_id 错误.
*/
CODE_47501(47501, "参数 activity_id 错误"),
/**
* 参数 target_state 错误.
*/
CODE_47502(47502, "参数 target_state 错误"),
/**
* 参数 version_type 错误.
*/
CODE_47503(47503, "参数 version_type 错误"),
/**
* activity_id 过期.
*/
CODE_47504(47504, "activity_id 过期"),
/**
* api 禁止清零调用次数,因为清零次数达到上限
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuota.html">参考文档</a>
*/
CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"),
/**
* rid不存在
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getRidInfo.html">参考文档</a>
*/
CODE_76001(76001, "rid不存在"),
/**
* rid为空或者格式错误
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getRidInfo.html">参考文档</a>
*/
CODE_76002(76002, "rid为空或者格式错误"),
/**
* 当前账号无权查询该rid,该rid属于其他账号调用所产生
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getRidInfo.html">参考文档</a>
*/
CODE_76003(76003, "当前账号无权查询该rid,该rid属于其他账号调用所产生"),
/**
* rid过期
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getRidInfo.html">参考文档</a>
*/
CODE_76004(76004, "rid过期,仅支持持续7天内的rid"),
/**
* cgi_path填错了
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getApiQuota.html">参考文档</a>
*/
CODE_76021(76021, "cgi_path填错了"),
/**
* 当前调用接口使用的token与api所属账号不符
*
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getApiQuota.html">参考文档</a>
*/
CODE_76022(76022, "当前调用接口使用的token与api所属账号不符,详情可看注意事项的说明"),
/**
* 没有绑定开放平台帐号.
*/
CODE_89002(89002, "没有绑定开放平台帐号"),
/**
* 订单无效.
*/
CODE_89300(89300, "订单无效"),
/**
* 代小程序实现业务的错误码,部分和小程序业务一致
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/Intro.html
*/
CODE_85060(85060, "无效的taskid"),
CODE_85027(85027, "身份证绑定管理员名额达到上限"),
CODE_85061(85061, "手机号绑定管理员名额达到上限"),
CODE_85026(85026, "微信号绑定管理员名额达到上限"),
CODE_85063(85063, "身份证黑名单"),
CODE_85062(85062, "手机号黑名单"),
CODE_85016(85016, "域名数量超过限制"),
CODE_85017(85017, "没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加"),
CODE_85018(85018, "域名没有在第三方平台设置"),
CODE_89019(89019, "业务域名无更改,无需重复设置"),
CODE_89020(89020, "尚未设置小程序业务域名,请先在第三方平台中设置小程序业务域名后在调用本接口"),
CODE_89021(89021, "请求保存的域名不是第三方平台中已设置的小程序业务域名或子域名"),
CODE_89029(89029, "业务域名数量超过限制"),
CODE_89231(89231, "个人小程序不支持调用 setwebviewdomain 接口"),
CODE_91001(91001, "不是公众号快速创建的小程序"),
CODE_91002(91002, "小程序发布后不可改名"),
CODE_91003(91003, "改名状态不合法"),
CODE_91004(91004, "昵称不合法"),
CODE_91005(91005, "昵称 15 天主体保护"),
CODE_91006(91006, "昵称命中微信号"),
CODE_91007(91007, "昵称已被占用"),
CODE_91008(91008, "昵称命中 7 天侵权保护期"),
CODE_91009(91009, "需要提交材料"),
CODE_91010(91010, "其他错误"),
CODE_91011(91011, "查不到昵称修改审核单信息"),
CODE_91012(91012, "其他错误"),
CODE_91013(91013, "占用名字过多"),
CODE_91014(91014, "+号规则 同一类型关联名主体不一致"),
CODE_91015(91015, "原始名不同类型主体不一致"),
CODE_91016(91016, "名称占用者 ≥2"),
CODE_91017(91017, "+号规则 不同类型关联名主体不一致"),
CODE_40097(40097, "参数错误"),
/**
* 缺少 appid 参数
* <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuotaByAppSecret.html">参考文档</a>
*/
CODE_41002(41002, "缺少 appid 参数"),
/**
* 缺少 secret 参数
* <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuotaByAppSecret.html">参考文档</a>
*/
CODE_41004(41004, "缺少 secret 参数"),
CODE_41006(41006, "media_id 不能为空"),
CODE_46001(46001, "media_id 不存在"),
CODE_40009(40009, "图片尺寸太大"),
CODE_53202(53202, "本月头像修改次数已用完"),
CODE_53200(53200, "本月功能介绍修改次数已用完"),
CODE_53201(53201, "功能介绍内容命中黑名单关键字"),
CODE_85083(85083, "搜索标记位被封禁,无法修改"),
CODE_85084(85084, "非法的 status 值,只能填 0 或者 1"),
CODE_85013(85013, "无效的自定义配置"),
CODE_85014(85014, "无效的模版编号"),
CODE_85043(85043, "模版错误"),
CODE_85044(85044, "代码包超过大小限制"),
CODE_85045(85045, "ext_json 有不存在的路径"),
CODE_85046(85046, "tabBar 中缺少 path"),
CODE_85047(85047, "pages 字段为空"),
CODE_85048(85048, "ext_json 解析失败"),
CODE_80082(80082, "没有权限使用该插件"),
CODE_80067(80067, "找不到使用的插件"),
CODE_80066(80066, "非法的插件版本"),
CODE_86000(86000, "不是由第三方代小程序进行调用"),
CODE_86001(86001, "不存在第三方的已经提交的代码"),
CODE_85006(85006, "标签格式错误"),
CODE_85007(85007, "页面路径错误"),
CODE_85008(85008, "类目填写错误"),
CODE_85009(85009, "已经有正在审核的版本"),
CODE_85010(85010, "item_list 有项目为空"),
CODE_85011(85011, "标题填写错误"),
CODE_85023(85023, "审核列表填写的项目数不在 1-5 以内"),
CODE_85077(85077, "小程序类目信息失效(类目中含有官方下架的类目,请重新选择类目)"),
CODE_86002(86002, "小程序还未设置昵称、头像、简介。请先设置完后再重新提交"),
CODE_85085(85085, "近 7 天提交审核的小程序数量过多,请耐心等待审核完毕后再次提交"),
CODE_85086(85086, "提交代码审核之前需提前上传代码"),
CODE_85087(85087, "小程序已使用 api navigateToMiniProgram,请声明跳转 appid 列表后再次提交"),
CODE_85012(85012, "无效的审核 id"),
CODE_87013(87013, "撤回次数达到上限(每天5次,每个月 10 次)"),
CODE_85019(85019, "没有审核版本"),
CODE_85020(85020, "审核状态未满足发布"),
CODE_87011(87011, "现网已经在灰度发布,不能进行版本回退"),
CODE_87012(87012, "该版本不能回退,可能的原因:1:无上一个线上版用于回退 2:此版本为已回退版本,不能回退 3:此版本为回退功能上线之前的版本,不能回退"),
CODE_85079(85079, "小程序没有线上版本,不能进行灰度"),
CODE_85080(85080, "小程序提交的审核未审核通过"),
CODE_85081(85081, "无效的发布比例"),
CODE_85082(85082, "当前的发布比例需要比之前设置的高"),
CODE_85021(85021, "状态不可变"),
CODE_85022(85022, "action 非法"),
CODE_89401(89401, "系统不稳定,请稍后再试,如多次失败请通过社区反馈"),
CODE_89402(89402, "该审核单不在待审核队列,请检查是否已提交审核或已审完"),
CODE_89403(89403, "本单属于平台不支持加急种类,请等待正常审核流程"),
CODE_89404(89404, "本单已加速成功,请勿重复提交"),
CODE_89405(89405, "本月加急额度不足,请提升提审质量以获取更多额度"),
CODE_85064(85064, "找不到模版/草稿"),
CODE_85065(85065, "模版库已满"),
/**
* 小程序订阅消息错误码
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html
*/
CODE_43101(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系"),
CODE_47003(47003, "模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错"),
/**
* 小程序绑定体验者
*/
CODE_85001(85001, "微信号不存在或微信号设置为不可搜索"),
CODE_85002(85002, "小程序绑定的体验者数量达到上限"),
CODE_85003(85003, "微信号绑定的小程序体验者达到上限"),
CODE_85004(85004, "微信号已经绑定"),
/**
* 53010
* 名称格式不合法
*/
CODE_53010(53010, "名称格式不合法"),
/**
* 53011
* 名称检测命中频率限制
*/
CODE_53011(53011, "名称检测命中频率限制"),
/**
* 53012
* 禁止使用该名称
*/
CODE_53012(53012, "禁止使用该名称"),
/**
* 53013
* 公众号:名称与已有公众号名称重复;小程序:该名称与已有小程序名称重复
*/
CODE_53013(53013, "公众号:名称与已有公众号名称重复;小程序:该名称与已有小程序名称重复"),
/**
* 53014
* 公众号:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}
*/
CODE_53014(53014, "公众号:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}"),
/**
* 53015
* 公众号:该名称与已有小程序名称重复,需与该小程序帐号相同主体才可申请;小程序:该名称与已有公众号名称重复,需与该公众号帐号相同主体才可申请
*/
CODE_53015(53015, "公众号:该名称与已有小程序名称重复,需与该小程序帐号相同主体才可申请;小程序:该名称与已有公众号名称重复,需与该公众号帐号相同主体才可申请"),
/**
* 53016
* 公众号:该名称与已有多个小程序名称重复,暂不支持申请;小程序:该名称与已有多个公众号名称重复,暂不支持申请
*/
CODE_53016(53016, "公众号:该名称与已有多个小程序名称重复,暂不支持申请;小程序:该名称与已有多个公众号名称重复,暂不支持申请"),
/**
* 53017
* 公众号:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}
*/
CODE_53017(53017, "公众号:小程序已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A};小程序:公众号已有{名称 A+}时,需与该帐号相同主体才可申请{名称 A}"),
/**
* 53018
* 名称命中微信号
*/
CODE_53018(53018, "名称命中微信号"),
/**
* 53019
* 名称在保护期内
*/
CODE_53019(53019, "名称在保护期内"),
/**
* 61070
* 法人姓名与微信号不一致 name, wechat name not in accordance
*/
CODE_61070(61070, "法人姓名与微信号不一致"),
/**
* 85015
* 该账号不是小程序账号
*/
CODE_85015(85015, "该账号不是小程序账号"),
/**
* 85066
* 链接错误
*/
CODE_85066(85066, "链接错误"),
/**
* 85068
* 测试链接不是子链接
*/
CODE_85068(85068, "测试链接不是子链接"),
/**
* 85069
* 校验文件失败
*/
CODE_85069(85069, "校验文件失败"),
/**
* 85070
* 个人类型小程序无法设置二维码规则
*/
CODE_85070(85070, "个人类型小程序无法设置二维码规则"),
/**
* 85071
* 已添加该链接,请勿重复添加
*/
CODE_85071(85071, "已添加该链接,请勿重复添加"),
/**
* 85072
* 该链接已被占用
*/
CODE_85072(85072, "该链接已被占用"),
/**
* 85073
* 二维码规则已满
*/
CODE_85073(85073, "二维码规则已满"),
/**
* 85074
* 小程序未发布, 小程序必须先发布代码才可以发布二维码跳转规则
*/
CODE_85074(85074, "小程序未发布, 小程序必须先发布代码才可以发布二维码跳转规则"),
/**
* 85075
* 个人类型小程序无法设置二维码规则
*/
CODE_85075(85075, "个人类型小程序无法设置二维码规则"),
/**
* 86004
* 无效微信号 invalid wechat
*/
CODE_86004(86004, "无效微信号"),
/**
* 89247
* 内部错误 inner error
*/
CODE_89247(89247, "内部错误"),
/**
* 89248
* 企业代码类型无效,请选择正确类型填写 invalid code_type type
*/
CODE_89248(89248, "企业代码类型无效,请选择正确类型填写"),
/**
* 89249
* 该主体已有任务执行中,距上次任务 24h 后再试 task running
*/
CODE_89249(89249, "该主体已有任务执行中,距上次任务 24h 后再试"),
/**
* 89250
* 未找到该任务 task not found
*/
CODE_89250(89250, "未找到该任务"),
/**
* 89251
* 待法人人脸核身校验 legal person checking
*/
CODE_89251(89251, "待法人人脸核身校验"),
/**
* 89252
* 法人&企业信息一致性校验中 front checking
*/
CODE_89252(89252, "法人&企业信息一致性校验中"),
/**
* 89253
* 缺少参数 lack of some params
*/
CODE_89253(89253, "缺少参数s"),
/**
* 89254
* 第三方权限集不全,补全权限集全网发布后生效 lack of some component rights
*/
CODE_89254(89254, "第三方权限集不全,补全权限集全网发布后生效"),
/**
* 89255
* code参数无效,请检查code长度以及内容是否正确 code参数无效,请检查code长度以及内容是否正确_;
* 注意code_type的值不同需要传的code长度不一样 ;注意code_type的值不同需要传的code长度不一样 enterprise code_invalid invalid
*/
CODE_89255(89255, "code参数无效,请检查code长度以及内容是否正确_;注意code_type的值不同需要传的code长度不一样 ;注意code_type的值不同需要传的code长度不一样"),
// CODE_504002(-504002, "云函数未找到 Function not found"),
/**
* 半屏小程序系统错误
*/
CODE_89408(89408, "半屏小程序系统错误"),
/**
* 获取半屏小程序列表参数错误
*/
CODE_89409(89409, "获取半屏小程序列表参数错误"),
/**
* 添加半屏小程序appid参数错误
*/
CODE_89410(89410, "添加半屏小程序appid参数错误"),
/**
* 添加半屏小程序appid参数为空
*/
CODE_89411(89411, "添加半屏小程序appid参数为空"),
/**
* 添加半屏小程序申请理由不得超过30个字
*/
CODE_89412(89412, "添加半屏小程序申请理由不得超过30个字"),
/**
* 该小程序被申请次数已达24h限制
*/
CODE_89413(89413, "该小程序被申请次数已达24h限制"),
/**
* 每天仅允许申请50次半屏小程序
*/
CODE_89414(89414, "每天仅允许申请50次半屏小程序"),
/**
* 删除半屏小程序appid参数为空
*/
CODE_89415(89415, "删除半屏小程序appid参数为空"),
/**
* 取消半屏小程序授权appid参数为空
*/
CODE_89416(89416, "取消半屏小程序授权appid参数为空"),
/**
* 修改半屏小程序方式flag参数错误
*/
CODE_89417(89417, "修改半屏小程序方式flag参数错误"),
/**
* 获取半屏小程序每日申请次数失败
*/
CODE_89418(89418, "获取半屏小程序每日申请次数失败"),
/**
* 获取半屏小程序每日授权次数失败
*/
CODE_89419(89419, "获取半屏小程序每日授权次数失败"),
/**
* 不支持添加个人主体小程序
*/
CODE_89420(89420, "不支持添加个人主体小程序"),
/**
* 删除数据未找到
*/
CODE_89421(89421, "删除数据未找到"),
/**
* 删除状态异常
*/
CODE_89422(89422, "删除状态异常"),
/**
* 申请次数添加到达上限
*/
CODE_89423(89423, "申请次数添加到达上限"),
/**
* 申请添加已超时
*/
CODE_89425(89425, "申请添加已超时"),
/**
* 申请添加状态异常
*/
CODE_89426(89426, "申请添加状态异常"),
/**
* 申请号和授权号相同
*/
CODE_89427(89427, "申请号和授权号相同"),
/**
* 该小程序已申请,不允许重复添加
*/
CODE_89428(89428, "该小程序已申请,不允许重复添加"),
/**
* 已到达同一小程序每日最多申请次数
*/
CODE_89429(89429, "已到达同一小程序每日最多申请次数"),
/**
* 该小程序已设置自动拒绝申请
*/
CODE_89430(89430, "该小程序已设置自动拒绝申请"),
/**
* 不支持此类型小程序
*/
CODE_89431(89431, "不支持此类型小程序"),
/**
* 不是小程序
*/
CODE_89432(89432, "不是小程序"),
/**
* 授权次数到达上限
*/
CODE_89424(89424, "授权次数到达上限"),
;
private final int code;
private final String msg;
WxMaErrorMsgEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
static final Map<Integer, String> valueMap = Maps.newHashMap();
static {
for (WxMaErrorMsgEnum value : WxMaErrorMsgEnum.values()) {
valueMap.put(value.code, value.msg);
}
}
/**
* 通过错误代码查找其中文含义.
*/
public static String findMsgByCode(int code) {
return valueMap.getOrDefault(code, null);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxChannelErrorMsgEnum.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxChannelErrorMsgEnum.java | package me.chanjar.weixin.common.error;
import com.google.common.collect.Maps;
import java.util.Map;
/**
*
* <pre>
* 微信小店公共错误码.
* 参考文档:<a href="https://developers.weixin.qq.com/doc/store/API/basics/commErrCode.html">微信小店公共错误码</a>
* </pre>
*
* @author Zeyes
*/
public enum WxChannelErrorMsgEnum {
/**
* 系统繁忙,此时请开发者稍候再试 system error
*/
CODE_1(-1, "系统繁忙,此时请开发者稍候再试"),
/**
* 请求成功 ok
*/
CODE_0(0, "请求成功"),
/**
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真检查 AppSecret 的正确性
* invalid credential, access_token is invalid or not latest, could get access_token by getStableAccessToken, more details at https://mmbizurl.cn/s/JtxxFh33r
*/
CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真检查 AppSecret 的正确性"),
/**
* 请检查 openid 的正确性
* invalid openid
*/
CODE_40003(40003, "请检查 openid 的正确性"),
/**
* 请检查 appid 的正确性,避免异常字符,注意大小写
* invalid appid
*/
CODE_40013(40013, "请检查 appid 的正确性,避免异常字符,注意大小写"),
/**
* 请检查API的URL是否与文档一致
* invalid url
*/
CODE_40066(40066, "请检查API的URL是否与文档一致"),
/**
* 缺少 access_token 参数
* access_token missing
*/
CODE_41001(41001, "缺少 access_token 参数"),
/**
* 请检查URL参数中是否有 ?appid=
* appid missing
*/
CODE_41002(41002, "请检查URL参数中是否有 ?appid="),
/**
* 请检查POST json中是否包含component_ appid宇段
* missing component_appid
*/
CODE_41018(41018, "请检查POST json中是否包含component_ appid宇段"),
/**
* access_token失效,需要重新获取新的access_token
* access_token expired
*/
CODE_42001(42001, "access_token失效,需要重新获取新的access_token"),
/**
* 请检查发起API请求的Method是否为POST
* require POST method
*/
CODE_43002(43002, "请检查发起API请求的Method是否为POST"),
/**
* 请使用HTTPS方式清求,不要使用HTTP方式
* require https
*/
CODE_43003(43003, "请使用HTTPS方式清求,不要使用HTTP方式"),
/**
* POST 的数据包为空
* empty post data
*/
CODE_44002(44002, "POST 的数据包为空"),
/**
* 请对数据进行压缩
* content size out of limit
*/
CODE_45002(45002, "请对数据进行压缩"),
/**
* 查看调用次数是否符合预期,可通过get_api_quota接口获取每天的调用quota;用完后可通过clear_quota进行清空
* reach max api daily quota limit
*/
CODE_45009(45009, "查看调用次数是否符合预期,可通过get_api_quota接口获取每天的调用quota;用完后可通过clear_quota进行清空"),
/**
* 命中每分钟的频率限制
* api minute-quota reach limit must slower retry next minute
*/
CODE_45011(45011, "命中每分钟的频率限制"),
/**
* 需要登录 channels.weixin.qq.com/shop 配置IP白名单
* access clientip is not registered, not in ip-white-list
*/
CODE_45035(45035, "需要登录 channels.weixin.qq.com/shop 配置IP白名单"),
/**
* 解析 JSON/XML 内容错误
* data format error
*/
CODE_47001(47001, "解析 JSON/XML 内容错误"),
/**
* 没有该接口权限
* api unauthorized
*/
CODE_48001(48001, "没有该接口权限"),
/**
* 接口被禁用
* api forbidden for irregularities
*/
CODE_48004(48004, "接口被禁用"),
/**
* 请找用户获取该api授权
* user unauthorized
*/
CODE_50001(50001, "请找用户获取该api授权"),
/**
* 请检查封禁原因
* user limited
*/
CODE_50002(50002, "请检查封禁原因"),
/**
* 需要登录 channels.weixin.qq.com/shop 配置IP白名单
* access clientip is not registered, not in ip-white-list
*/
CODE_61004(61004, "需要登录 channels.weixin.qq.com/shop 配置IP白名单"),
/**
* 请检查第三方平台服务商检查已获取的授权集
* api is unauthorized to component
*/
CODE_61007(61007, "请检查第三方平台服务商检查已获取的授权集"),
/**
* 需要登录 channels.weixin.qq.com/shop 继续完成注销
* 账号发起注销,进入注销公示期
*/
CODE_10080000(10080000, "需要登录 channels.weixin.qq.com/shop 继续完成注销"),
/**
* 账号已注销
*/
CODE_10080001(10080001, "账号已注销"),
/**
* 小店的视频号带货身份为达人号,不允许使用该功能,如需使用,请将带货身份修改为商家
*/
CODE_10080002(10080002, "小店的视频号带货身份为达人号,不允许使用该功能,如需使用,请将带货身份修改为商家"),
;
private final int code;
private final String msg;
WxChannelErrorMsgEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
static final Map<Integer, String> valueMap = Maps.newHashMap();
static {
for (WxChannelErrorMsgEnum value : WxChannelErrorMsgEnum.values()) {
valueMap.put(value.code, value.msg);
}
}
/**
* 通过错误代码查找其中文含义.
*/
public static String findMsgByCode(int code) {
return valueMap.getOrDefault(code, null);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxError.java | package me.chanjar.weixin.common.error;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
/**
* 微信错误码.
* 请阅读:
* 公众平台:<a href="https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Global_Return_Code.html">全局返回码说明</a>
* 企业微信:<a href="https://work.weixin.qq.com/api/doc#10649">全局错误码</a>
*
* @author Daniel Qian & Binary Wang
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WxError implements Serializable {
private static final long serialVersionUID = 7869786563361406291L;
/**
* 微信错误代码.
*/
private int errorCode;
/**
* 微信错误信息.
* (如果可以翻译为中文,就为中文)
*/
private String errorMsg;
/**
* 微信接口返回的错误原始信息(英文).
*/
private String errorMsgEn;
private String json;
public WxError(int errorCode, String errorMsg) {
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public static WxError fromJson(String json) {
return fromJson(json, null);
}
public static WxError fromJson(String json, WxType type) {
final WxError wxError = WxGsonBuilder.create().fromJson(json, WxError.class);
if (wxError.getErrorCode() == 0 || type == null) {
return wxError;
}
if (StringUtils.isNotEmpty(wxError.getErrorMsg())) {
wxError.setErrorMsgEn(wxError.getErrorMsg());
}
switch (type) {
case MP: {
final String msg = WxMpErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
if (msg != null) {
wxError.setErrorMsg(msg);
}
break;
}
case CP: {
final String msg = WxCpErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
if (msg != null) {
wxError.setErrorMsg(msg);
}
break;
}
case MiniApp: {
final String msg = WxMaErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
if (msg != null) {
wxError.setErrorMsg(msg);
}
break;
}
case Open: {
final String msg = WxOpenErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
if (msg != null) {
wxError.setErrorMsg(msg);
}
break;
}
case Channel: {
final String msg = WxChannelErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
if (msg != null) {
wxError.setErrorMsg(msg);
}
break;
}
default:
return wxError;
}
return wxError;
}
@Override
public String toString() {
if (this.json == null) {
return "错误代码:" + this.errorCode + ", 错误信息:" + this.errorMsg;
}
return "错误代码:" + this.errorCode + ", 错误信息:" + this.errorMsg + ",微信原始报文:" + this.json;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxMpErrorMsgEnum.java | package me.chanjar.weixin.common.error;
import com.google.common.collect.Maps;
import lombok.Getter;
import java.util.Map;
/**
* <pre>
* 微信公众平台全局返回码.
* 参考文档:<a href="https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Global_Return_Code.html">公众平台全局返回码</a>
* Created by Binary Wang on 2018/5/13.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Getter
public enum WxMpErrorMsgEnum {
/**
* 系统繁忙,此时请开发者稍候再试.
*/
CODE_1(-1, "系统繁忙,此时请开发者稍候再试"),
/**
* 请求成功.
*/
CODE_0(0, "请求成功"),
/**
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口.
*/
CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"),
/**
* 不合法的凭证类型.
*/
CODE_40002(40002, "不合法的凭证类型"),
/**
* 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID.
*/
CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"),
/**
* 不合法的媒体文件类型.
*/
CODE_40004(40004, "不合法的媒体文件类型"),
/**
* 不合法的文件类型.
*/
CODE_40005(40005, "不合法的文件类型"),
/**
* 不合法的文件大小.
*/
CODE_40006(40006, "不合法的文件大小"),
/**
* 不合法的媒体文件 id.
*/
CODE_40007(40007, "不合法的媒体文件 id"),
/**
* 不合法的消息类型.
*/
CODE_40008(40008, "不合法的消息类型"),
/**
* 不合法的图片文件大小.
*/
CODE_40009(40009, "不合法的图片文件大小"),
/**
* 不合法的语音文件大小.
*/
CODE_40010(40010, "不合法的语音文件大小"),
/**
* 不合法的视频文件大小.
*/
CODE_40011(40011, "不合法的视频文件大小"),
/**
* 不合法的缩略图文件大小.
*/
CODE_40012(40012, "不合法的缩略图文件大小"),
/**
* 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写.
*/
CODE_40013(40013, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"),
/**
* 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口.
*/
CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"),
/**
* 不合法的菜单类型.
*/
CODE_40015(40015, "不合法的菜单类型"),
/**
* 不合法的按钮个数.
*/
CODE_40016(40016, "不合法的按钮个数"),
/**
* 不合法的按钮类型.
*/
CODE_40017(40017, "不合法的按钮类型"),
/**
* 不合法的按钮名字长度.
*/
CODE_40018(40018, "不合法的按钮名字长度"),
/**
* 不合法的按钮 KEY 长度.
*/
CODE_40019(40019, "不合法的按钮 KEY 长度"),
/**
* 不合法的按钮 URL 长度.
*/
CODE_40020(40020, "不合法的按钮 URL 长度"),
/**
* 不合法的菜单版本号.
*/
CODE_40021(40021, "不合法的菜单版本号"),
/**
* 不合法的子菜单级数.
*/
CODE_40022(40022, "不合法的子菜单级数"),
/**
* 不合法的子菜单按钮个数.
*/
CODE_40023(40023, "不合法的子菜单按钮个数"),
/**
* 不合法的子菜单按钮类型.
*/
CODE_40024(40024, "不合法的子菜单按钮类型"),
/**
* 不合法的子菜单按钮名字长度.
*/
CODE_40025(40025, "不合法的子菜单按钮名字长度"),
/**
* 不合法的子菜单按钮 KEY 长度.
*/
CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"),
/**
* 不合法的子菜单按钮 URL 长度.
*/
CODE_40027(40027, "不合法的子菜单按钮 URL 长度"),
/**
* 不合法的自定义菜单使用用户.
*/
CODE_40028(40028, "不合法的自定义菜单使用用户"),
/**
* 不合法的 oauth_code.
*/
CODE_40029(40029, "不合法的 oauth_code"),
/**
* 不合法的 refresh_token.
*/
CODE_40030(40030, "不合法的 refresh_token"),
/**
* 不合法的 openid 列表.
*/
CODE_40031(40031, "不合法的 openid 列表"),
/**
* 不合法的 openid 列表长度.
*/
CODE_40032(40032, "不合法的 openid 列表长度"),
/**
* 不合法的请求字符,不能包含\\uxxxx 格式的字符.
*/
CODE_40033(40033, "不合法的请求字符,不能包含\\uxxxx 格式的字符"),
/**
* 不合法的参数.
*/
CODE_40035(40035, "不合法的参数"),
/**
* 不合法的请求格式.
*/
CODE_40038(40038, "不合法的请求格式"),
/**
* 不合法的 URL 长度.
*/
CODE_40039(40039, "不合法的 URL 长度"),
/**
* 不合法的分组 id.
*/
CODE_40050(40050, "不合法的分组 id"),
/**
* 分组名字不合法.
*/
CODE_40051(40051, "分组名字不合法"),
/**
* 删除单篇图文时,指定的 article_idx 不合法.
*/
CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"),
/**
* 分组名字不合法.
*/
CODE_40117(40117, "分组名字不合法"),
/**
* media_id 大小不合法.
*/
CODE_40118(40118, "media_id 大小不合法"),
/**
* button 类型错误.
*/
CODE_40119(40119, "button 类型错误"),
/**
* button 类型错误.
*/
CODE_40120(40120, "button 类型错误"),
/**
* 不合法的 media_id 类型.
*/
CODE_40121(40121, "不合法的 media_id 类型"),
/**
* 微信号不合法.
*/
CODE_40132(40132, "微信号不合法"),
/**
* 不支持的图片格式.
*/
CODE_40137(40137, "不支持的图片格式"),
/**
* 请勿添加其他公众号的主页链接.
*/
CODE_40155(40155, "请勿添加其他公众号的主页链接"),
/**
* oauth_code已使用
*/
CODE_40163(40163, "oauth_code已使用"),
/**
* 缺少 access_token 参数.
*/
CODE_41001(41001, "缺少 access_token 参数"),
/**
* 缺少 appid 参数.
*/
CODE_41002(41002, "缺少 appid 参数"),
/**
* 缺少 refresh_token 参数.
*/
CODE_41003(41003, "缺少 refresh_token 参数"),
/**
* 缺少 secret 参数.
*/
CODE_41004(41004, "缺少 secret 参数"),
/**
* 缺少多媒体文件数据.
*/
CODE_41005(41005, "缺少多媒体文件数据"),
/**
* 缺少 media_id 参数.
*/
CODE_41006(41006, "缺少 media_id 参数"),
/**
* 缺少子菜单数据.
*/
CODE_41007(41007, "缺少子菜单数据"),
/**
* 缺少 oauth code.
*/
CODE_41008(41008, "缺少 oauth code"),
/**
* 缺少 openid.
*/
CODE_41009(41009, "缺少 openid"),
/**
* access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明.
*/
CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"),
/**
* refresh_token 超时.
*/
CODE_42002(42002, "refresh_token 超时"),
/**
* oauth_code 超时.
*/
CODE_42003(42003, "oauth_code 超时"),
/**
* 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权.
*/
CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"),
/**
* 需要 GET 请求.
*/
CODE_43001(43001, "需要 GET 请求"),
/**
* 需要 POST 请求.
*/
CODE_43002(43002, "需要 POST 请求"),
/**
* 需要 HTTPS 请求.
*/
CODE_43003(43003, "需要 HTTPS 请求"),
/**
* 需要接收者关注.
*/
CODE_43004(43004, "需要接收者关注"),
/**
* 需要好友关系.
*/
CODE_43005(43005, "需要好友关系"),
/**
* 需要将接收者从黑名单中移除.
*/
CODE_43019(43019, "需要将接收者从黑名单中移除"),
/**
* 多媒体文件为空.
*/
CODE_44001(44001, "多媒体文件为空"),
/**
* POST 的数据包为空.
*/
CODE_44002(44002, "POST 的数据包为空"),
/**
* 图文消息内容为空.
*/
CODE_44003(44003, "图文消息内容为空"),
/**
* 文本消息内容为空.
*/
CODE_44004(44004, "文本消息内容为空"),
/**
* 多媒体文件大小超过限制.
*/
CODE_45001(45001, "多媒体文件大小超过限制"),
/**
* 消息内容超过限制.
*/
CODE_45002(45002, "消息内容超过限制"),
/**
* 标题字段超过限制.
*/
CODE_45003(45003, "标题字段超过限制"),
/**
* 描述字段超过限制.
*/
CODE_45004(45004, "描述字段超过限制"),
/**
* 链接字段超过限制.
*/
CODE_45005(45005, "链接字段超过限制"),
/**
* 图片链接字段超过限制.
*/
CODE_45006(45006, "图片链接字段超过限制"),
/**
* 语音播放时间超过限制.
*/
CODE_45007(45007, "语音播放时间超过限制"),
/**
* 图文消息超过限制.
*/
CODE_45008(45008, "图文消息超过限制"),
/**
* 接口调用超过限制.
*/
CODE_45009(45009, "接口调用超过限制"),
/**
* 创建菜单个数超过限制.
*/
CODE_45010(45010, "创建菜单个数超过限制"),
/**
* API 调用太频繁,请稍候再试.
*/
CODE_45011(45011, "API 调用太频繁,请稍候再试"),
/**
* 回复时间超过限制.
*/
CODE_45015(45015, "回复时间超过限制"),
/**
* 系统分组,不允许修改.
*/
CODE_45016(45016, "系统分组,不允许修改"),
/**
* 分组名字过长.
*/
CODE_45017(45017, "分组名字过长"),
/**
* 分组数量超过上限.
*/
CODE_45018(45018, "分组数量超过上限"),
/**
* 客服接口下行条数超过上限.
*/
CODE_45047(45047, "客服接口下行条数超过上限"),
/**
* 非法的tag_id.
*/
CODE_45159(45159, "非法的tag_id"),
/**
* 相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid
*/
CODE_45065(45065, "相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid"),
/**
* 相同 clientmsgid 重试速度过快,请间隔1分钟重试
*/
CODE_45066(45066, "相同 clientmsgid 重试速度过快,请间隔1分钟重试"),
/**
* clientmsgid 长度超过限制
*/
CODE_45067(45067, "clientmsgid 长度超过限制"),
/**
* 不存在媒体数据.
*/
CODE_46001(46001, "不存在媒体数据"),
/**
* 不存在的菜单版本.
*/
CODE_46002(46002, "不存在的菜单版本"),
/**
* 不存在的菜单数据.
*/
CODE_46003(46003, "不存在的菜单数据"),
/**
* 不存在的用户.
*/
CODE_46004(46004, "不存在的用户"),
/**
* 解析 JSON/XML 内容错误.
*/
CODE_47001(47001, "解析 JSON/XML 内容错误"),
/**
* api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限.
*/
CODE_48001(48001, "api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"),
/**
* 粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” ).
*/
CODE_48002(48002, "粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” )"),
/**
* api 接口被封禁,请登录 mp.weixin.qq.com 查看详情.
*/
CODE_48004(48004, "api 接口被封禁,请登录 mp.weixin.qq.com 查看详情"),
/**
* api 禁止删除被自动回复和自定义菜单引用的素材.
*/
CODE_48005(48005, "api 禁止删除被自动回复和自定义菜单引用的素材"),
/**
* api 禁止清零调用次数,因为清零次数达到上限.
*/
CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"),
/**
* 没有该类型消息的发送权限.
*/
CODE_48008(48008, "没有该类型消息的发送权限"),
/**
* 用户未授权该 api.
*/
CODE_50001(50001, "用户未授权该 api"),
/**
* 用户受限,可能是违规后接口被封禁.
*/
CODE_50002(50002, "用户受限,可能是违规后接口被封禁"),
/**
* 用户未关注公众号.
*/
CODE_50005(50005, "用户未关注公众号"),
/**
* 参数错误 (invalid parameter).
*/
CODE_61451(61451, "参数错误 (invalid parameter)"),
/**
* 无效客服账号 (invalid kf_account).
*/
CODE_61452(61452, "无效客服账号 (invalid kf_account)"),
/**
* 客服帐号已存在 (kf_account exsited).
*/
CODE_61453(61453, "客服帐号已存在 (kf_account exsited)"),
/**
* 客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length).
*/
CODE_61454(61454, "客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length)"),
/**
* 客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account).
*/
CODE_61455(61455, "客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account)"),
/**
* 客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded).
*/
CODE_61456(61456, "客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded)"),
/**
* 无效头像文件类型 (invalid file type).
*/
CODE_61457(61457, "无效头像文件类型 (invalid file type)"),
/**
* 系统错误 (system error).
*/
CODE_61450(61450, "系统错误 (system error)"),
/**
* 日期格式错误.
*/
CODE_61500(61500, "日期格式错误"),
/**
* 不存在此 menuid 对应的个性化菜单.
*/
CODE_65301(65301, "不存在此 menuid 对应的个性化菜单"),
/**
* 没有相应的用户.
*/
CODE_65302(65302, "没有相应的用户"),
/**
* 没有默认菜单,不能创建个性化菜单.
*/
CODE_65303(65303, "没有默认菜单,不能创建个性化菜单"),
/**
* MatchRule 信息为空.
*/
CODE_65304(65304, "MatchRule 信息为空"),
/**
* 个性化菜单数量受限.
*/
CODE_65305(65305, "个性化菜单数量受限"),
/**
* 不支持个性化菜单的帐号.
*/
CODE_65306(65306, "不支持个性化菜单的帐号"),
/**
* 个性化菜单信息为空.
*/
CODE_65307(65307, "个性化菜单信息为空"),
/**
* 包含没有响应类型的 button.
*/
CODE_65308(65308, "包含没有响应类型的 button"),
/**
* 个性化菜单开关处于关闭状态.
*/
CODE_65309(65309, "个性化菜单开关处于关闭状态"),
/**
* 填写了省份或城市信息,国家信息不能为空.
*/
CODE_65310(65310, "填写了省份或城市信息,国家信息不能为空"),
/**
* 填写了城市信息,省份信息不能为空.
*/
CODE_65311(65311, "填写了城市信息,省份信息不能为空"),
/**
* 不合法的国家信息.
*/
CODE_65312(65312, "不合法的国家信息"),
/**
* 不合法的省份信息.
*/
CODE_65313(65313, "不合法的省份信息"),
/**
* 不合法的城市信息.
*/
CODE_65314(65314, "不合法的城市信息"),
/**
* 该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接).
*/
CODE_65316(65316, "该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接)"),
/**
* 不合法的 URL.
*/
CODE_65317(65317, "不合法的 URL"),
/**
* POST 数据参数不合法.
*/
CODE_9001001(9001001, "POST 数据参数不合法"),
/**
* 远端服务不可用.
*/
CODE_9001002(9001002, "远端服务不可用"),
/**
* Ticket 不合法.
*/
CODE_9001003(9001003, "Ticket 不合法"),
/**
* 获取摇周边用户信息失败.
*/
CODE_9001004(9001004, "获取摇周边用户信息失败"),
/**
* 获取商户信息失败.
*/
CODE_9001005(9001005, "获取商户信息失败"),
/**
* 获取 OpenID 失败.
*/
CODE_9001006(9001006, "获取 OpenID 失败"),
/**
* 上传文件缺失.
*/
CODE_9001007(9001007, "上传文件缺失"),
/**
* 上传素材的文件类型不合法.
*/
CODE_9001008(9001008, "上传素材的文件类型不合法"),
/**
* 上传素材的文件尺寸不合法.
*/
CODE_9001009(9001009, "上传素材的文件尺寸不合法"),
/**
* 上传失败.
*/
CODE_9001010(9001010, "上传失败"),
/**
* 帐号不合法.
*/
CODE_9001020(9001020, "帐号不合法"),
/**
* 已有设备激活率低于 50% ,不能新增设备.
*/
CODE_9001021(9001021, "已有设备激活率低于 50% ,不能新增设备"),
/**
* 设备申请数不合法,必须为大于 0 的数字.
*/
CODE_9001022(9001022, "设备申请数不合法,必须为大于 0 的数字"),
/**
* 已存在审核中的设备 ID 申请.
*/
CODE_9001023(9001023, "已存在审核中的设备 ID 申请"),
/**
* 一次查询设备 ID 数量不能超过 50.
*/
CODE_9001024(9001024, "一次查询设备 ID 数量不能超过 50"),
/**
* 设备 ID 不合法.
*/
CODE_9001025(9001025, "设备 ID 不合法"),
/**
* 页面 ID 不合法.
*/
CODE_9001026(9001026, "页面 ID 不合法"),
/**
* 页面参数不合法.
*/
CODE_9001027(9001027, "页面参数不合法"),
/**
* 一次删除页面 ID 数量不能超过 10.
*/
CODE_9001028(9001028, "一次删除页面 ID 数量不能超过 10"),
/**
* 页面已应用在设备中,请先解除应用关系再删除.
*/
CODE_9001029(9001029, "页面已应用在设备中,请先解除应用关系再删除"),
/**
* 一次查询页面 ID 数量不能超过 50.
*/
CODE_9001030(9001030, "一次查询页面 ID 数量不能超过 50"),
/**
* 时间区间不合法.
*/
CODE_9001031(9001031, "时间区间不合法"),
/**
* 保存设备与页面的绑定关系参数错误.
*/
CODE_9001032(9001032, "保存设备与页面的绑定关系参数错误"),
/**
* 门店 ID 不合法.
*/
CODE_9001033(9001033, "门店 ID 不合法"),
/**
* 设备备注信息过长.
*/
CODE_9001034(9001034, "设备备注信息过长"),
/**
* 设备申请参数不合法.
*/
CODE_9001035(9001035, "设备申请参数不合法"),
/**
* 查询起始值 begin 不合法.
*/
CODE_9001036(9001036, "查询起始值 begin 不合法"),
/**
* 设置的 speed 参数不在0到4的范围内
*/
CODE_45083(45083, "设置的 speed 参数不在0到4的范围内"),
/**
* 没有设置 speed 参数
*/
CODE_45084(45084, "没有设置 speed 参数");
private final int code;
private final String msg;
WxMpErrorMsgEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
static final Map<Integer, String> valueMap = Maps.newHashMap();
static {
for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) {
valueMap.put(value.code, value.msg);
}
}
/**
* 通过错误代码查找其中文含义..
*/
public static String findMsgByCode(int code) {
return valueMap.getOrDefault(code, null);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxErrorException.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxErrorException.java | package me.chanjar.weixin.common.error;
/**
* @author Daniel Qian
*/
public class WxErrorException extends Exception {
private static final long serialVersionUID = -6357149550353160810L;
private final WxError error;
private static final int DEFAULT_ERROR_CODE = -99;
public WxErrorException(String message) {
this(WxError.builder().errorCode(DEFAULT_ERROR_CODE).errorMsg(message).build());
}
public WxErrorException(WxError error) {
super(error.toString());
this.error = error;
}
public WxErrorException(WxError error, Throwable cause) {
super(error.toString(), cause);
this.error = error;
}
public WxErrorException(Throwable cause) {
super(cause.getMessage(), cause);
this.error = WxError.builder().errorCode(DEFAULT_ERROR_CODE).errorMsg(cause.getMessage()).build();
}
public WxError getError() {
return this.error;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java | package me.chanjar.weixin.common.error;
import com.google.common.collect.Maps;
import lombok.Getter;
import java.util.Map;
/**
* <pre>
* 微信开放平台全局返回码.
* 参考文档:<a href="https://developers.weixin.qq.com/doc/oplatform/Return_codes/Return_code_descriptions_new.html">开放平台全局返回码</a>
* </pre>
*
* @author Lam Jerry
*/
@Getter
public enum WxOpenErrorMsgEnum {
/**
* 系统繁忙,此时请开发者稍候再试 system error
*/
CODE_1(-1, "系统繁忙,此时请开发者稍候再试"),
/**
* 请求成功 ok
*/
CODE_0(0, "请求成功"),
/**
* POST参数非法
*/
CODE_1003(1003, "POST参数非法"),
/**
* 商品id不存在
*/
CODE_20002(20002, "商品id不存在"),
/**
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 invalid credential, access_token is invalid or not latest
*/
CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"),
/**
* 不合法的凭证类型 invalid grant_type
*/
CODE_40002(40002, "不合法的凭证类型"),
/**
* 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID invalid openid
*/
CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"),
/**
* 不合法的媒体文件类型 invalid media type
*/
CODE_40004(40004, "不合法的媒体文件类型"),
/**
* 上传素材文件格式不对 invalid file type
*/
CODE_40005(40005, "上传素材文件格式不对"),
/**
* 上传素材文件大小超出限制 invalid meida size
*/
CODE_40006(40006, "上传素材文件大小超出限制"),
/**
* 不合法的媒体文件 id invalid media_id
*/
CODE_40007(40007, "不合法的媒体文件 id"),
/**
* 不合法的消息类型 invalid message type
*/
CODE_40008(40008, "不合法的消息类型"),
/**
* 图片尺寸太大 invalid image size
*/
CODE_40009(40009, "图片尺寸太大"),
/**
* 不合法的语音文件大小 invalid voice size
*/
CODE_40010(40010, "不合法的语音文件大小"),
/**
* 不合法的视频文件大小 invalid video size
*/
CODE_40011(40011, "不合法的视频文件大小"),
/**
* 不合法的缩略图文件大小 invalid thumb size
*/
CODE_40012(40012, "不合法的缩略图文件大小"),
/**
* 不合法的appid invalid appid
*/
CODE_40013(40013, "不合法的appid"),
/**
* 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口 invalid access_token
*/
CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"),
/**
* 不合法的菜单类型 invalid menu type
*/
CODE_40015(40015, "不合法的菜单类型"),
/**
* 不合法的按钮个数 invalid button size
*/
CODE_40016(40016, "不合法的按钮个数"),
/**
* 不合法的按钮类型 invalid button type
*/
CODE_40017(40017, "不合法的按钮类型"),
/**
* 不合法的按钮名字长度 invalid button name size
*/
CODE_40018(40018, "不合法的按钮名字长度"),
/**
* 不合法的按钮 KEY 长度 invalid button key size
*/
CODE_40019(40019, "不合法的按钮 KEY 长度"),
/**
* 不合法的按钮 URL 长度 invalid button url size
*/
CODE_40020(40020, "不合法的按钮 URL 长度"),
/**
* 不合法的菜单版本号 invalid menu version
*/
CODE_40021(40021, "不合法的菜单版本号"),
/**
* 不合法的子菜单级数 invalid sub_menu level
*/
CODE_40022(40022, "不合法的子菜单级数"),
/**
* 不合法的子菜单按钮个数 invalid sub button size
*/
CODE_40023(40023, "不合法的子菜单按钮个数"),
/**
* 不合法的子菜单按钮类型 invalid sub button type
*/
CODE_40024(40024, "不合法的子菜单按钮类型"),
/**
* 不合法的子菜单按钮名字长度 invalid sub button name size
*/
CODE_40025(40025, "不合法的子菜单按钮名字长度"),
/**
* 不合法的子菜单按钮 KEY 长度 invalid sub button key size
*/
CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"),
/**
* 不合法的子菜单按钮 URL 长度 invalid sub button url size
*/
CODE_40027(40027, "不合法的子菜单按钮 URL 长度"),
/**
* 不合法的自定义菜单使用用户 invalid menu api user
*/
CODE_40028(40028, "不合法的自定义菜单使用用户"),
/**
* 无效的 oauth_code invalid code
*/
CODE_40029(40029, "无效的 oauth_code"),
/**
* 不合法的 refresh_token invalid refresh_token
*/
CODE_40030(40030, "不合法的 refresh_token"),
/**
* 不合法的 openid 列表 invalid openid list
*/
CODE_40031(40031, "不合法的 openid 列表"),
/**
* 不合法的 openid 列表长度 invalid openid list size
*/
CODE_40032(40032, "不合法的 openid 列表长度"),
/**
* 不合法的请求字符,不能包含 \\uxxxx 格式的字符 invalid charset. please check your request, if include \\uxxxx will create fail!
*/
CODE_40033(40033, "不合法的请求字符,不能包含 \\uxxxx 格式的字符"),
/**
* invalid template size
*/
CODE_40034(40034, "invalid template size"),
/**
* 不合法的参数 invalid args size
*/
CODE_40035(40035, "不合法的参数"),
/**
* 不合法的 template_id 长度 invalid template_id size
*/
CODE_40036(40036, "不合法的 template_id 长度"),
/**
* 不合法的 template_id invalid template_id
*/
CODE_40037(40037, "不合法的 template_id"),
/**
* 不合法的请求格式 invalid packaging type
*/
CODE_40038(40038, "不合法的请求格式"),
/**
* 不合法的 URL 长度 invalid url size
*/
CODE_40039(40039, "不合法的 URL 长度"),
/**
* invalid plugin token
*/
CODE_40040(40040, "invalid plugin token"),
/**
* invalid plugin id
*/
CODE_40041(40041, "invalid plugin id"),
/**
* invalid plugin session
*/
CODE_40042(40042, "invalid plugin session"),
/**
* invalid fav type
*/
CODE_40043(40043, "invalid fav type"),
/**
* invalid size in link.title
*/
CODE_40044(40044, "invalid size in link.title"),
/**
* invalid size in link.description
*/
CODE_40045(40045, "invalid size in link.description"),
/**
* invalid size in link.iconurl
*/
CODE_40046(40046, "invalid size in link.iconurl"),
/**
* invalid size in link.url
*/
CODE_40047(40047, "invalid size in link.url"),
/**
* 无效的url invalid url domain
*/
CODE_40048(40048, "无效的url"),
/**
* invalid score report type
*/
CODE_40049(40049, "invalid score report type"),
/**
* 不合法的分组 id invalid timeline type
*/
CODE_40050(40050, "不合法的分组 id"),
/**
* 分组名字不合法 invalid group name
*/
CODE_40051(40051, "分组名字不合法"),
/**
* invalid action name
*/
CODE_40052(40052, "invalid action name"),
/**
* invalid action info, please check document
*/
CODE_40053(40053, "invalid action info, please check document"),
/**
* 不合法的子菜单按钮 url 域名 invalid sub button url domain
*/
CODE_40054(40054, "不合法的子菜单按钮 url 域名"),
/**
* 不合法的菜单按钮 url 域名 invalid button url domain
*/
CODE_40055(40055, "不合法的菜单按钮 url 域名"),
/**
* invalid serial code
*/
CODE_40056(40056, "invalid serial code"),
/**
* invalid tabbar size
*/
CODE_40057(40057, "invalid tabbar size"),
/**
* invalid tabbar name size
*/
CODE_40058(40058, "invalid tabbar name size"),
/**
* invalid msg id
*/
CODE_40059(40059, "invalid msg id"),
/**
* 删除单篇图文时,指定的 article_idx 不合法 invalid article idx
*/
CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"),
/**
* invalid title size
*/
CODE_40062(40062, "invalid title size"),
/**
* invalid message_ext size
*/
CODE_40063(40063, "invalid message_ext size"),
/**
* invalid app type
*/
CODE_40064(40064, "invalid app type"),
/**
* invalid msg status
*/
CODE_40065(40065, "invalid msg status"),
/**
* 不合法的 url ,递交的页面被sitemap标记为拦截 invalid url
*/
CODE_40066(40066, "不合法的 url ,递交的页面被sitemap标记为拦截"),
/**
* invalid tvid
*/
CODE_40067(40067, "invalid tvid"),
/**
* contain mailcious url
*/
CODE_40068(40068, "contain mailcious url"),
/**
* invalid hardware type
*/
CODE_40069(40069, "invalid hardware type"),
/**
* invalid sku info
*/
CODE_40070(40070, "invalid sku info"),
/**
* invalid card type
*/
CODE_40071(40071, "invalid card type"),
/**
* invalid location id
*/
CODE_40072(40072, "invalid location id"),
/**
* invalid card id
*/
CODE_40073(40073, "invalid card id"),
/**
* invalid pay template id
*/
CODE_40074(40074, "invalid pay template id"),
/**
* invalid encrypt code
*/
CODE_40075(40075, "invalid encrypt code"),
/**
* invalid color id
*/
CODE_40076(40076, "invalid color id"),
/**
* invalid score type
*/
CODE_40077(40077, "invalid score type"),
/**
* invalid card status
*/
CODE_40078(40078, "invalid card status"),
/**
* invalid time
*/
CODE_40079(40079, "invalid time"),
/**
* invalid card ext
*/
CODE_40080(40080, "invalid card ext"),
/**
* invalid template_id
*/
CODE_40081(40081, "invalid template_id"),
/**
* invalid banner picture size
*/
CODE_40082(40082, "invalid banner picture size"),
/**
* invalid banner url size
*/
CODE_40083(40083, "invalid banner url size"),
/**
* invalid button desc size
*/
CODE_40084(40084, "invalid button desc size"),
/**
* invalid button url size
*/
CODE_40085(40085, "invalid button url size"),
/**
* invalid sharelink logo size
*/
CODE_40086(40086, "invalid sharelink logo size"),
/**
* invalid sharelink desc size
*/
CODE_40087(40087, "invalid sharelink desc size"),
/**
* invalid sharelink title size
*/
CODE_40088(40088, "invalid sharelink title size"),
/**
* invalid platform id
*/
CODE_40089(40089, "invalid platform id"),
/**
* invalid request source (bad client ip)
*/
CODE_40090(40090, "invalid request source (bad client ip)"),
/**
* invalid component ticket
*/
CODE_40091(40091, "invalid component ticket"),
/**
* invalid remark name
*/
CODE_40092(40092, "invalid remark name"),
/**
* not completely ok, err_item will return location_id=-1,check your required_fields in json.
*/
CODE_40093(40093, "not completely ok, err_item will return location_id=-1,check your required_fields in json."),
/**
* invalid component credential
*/
CODE_40094(40094, "invalid component credential"),
/**
* bad source of caller
*/
CODE_40095(40095, "bad source of caller"),
/**
* invalid biztype
*/
CODE_40096(40096, "invalid biztype"),
/**
* 参数错误 invalid args
*/
CODE_40097(40097, "参数错误"),
/**
* invalid poiid
*/
CODE_40098(40098, "invalid poiid"),
/**
* invalid code, this code has consumed.
*/
CODE_40099(40099, "invalid code, this code has consumed."),
/**
* invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime
*/
CODE_40100(40100, "invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime"),
/**
* missing parameter
*/
CODE_40101(40101, "missing parameter"),
/**
* invalid industry id
*/
CODE_40102(40102, "invalid industry id"),
/**
* invalid industry index
*/
CODE_40103(40103, "invalid industry index"),
/**
* invalid category id
*/
CODE_40104(40104, "invalid category id"),
/**
* invalid view type
*/
CODE_40105(40105, "invalid view type"),
/**
* invalid user name
*/
CODE_40106(40106, "invalid user name"),
/**
* invalid card id! 1,card status must verify ok; 2,this card must have location_id
*/
CODE_40107(40107, "invalid card id! 1,card status must verify ok; 2,this card must have location_id"),
/**
* invalid client version
*/
CODE_40108(40108, "invalid client version"),
/**
* too many code size, must <= 100
*/
CODE_40109(40109, "too many code size, must <= 100"),
/**
* have empty code
*/
CODE_40110(40110, "have empty code"),
/**
* have same code
*/
CODE_40111(40111, "have same code"),
/**
* can not set bind openid
*/
CODE_40112(40112, "can not set bind openid"),
/**
* unsupported file type
*/
CODE_40113(40113, "unsupported file type"),
/**
* invalid index value
*/
CODE_40114(40114, "invalid index value"),
/**
* invalid session from
*/
CODE_40115(40115, "invalid session from"),
/**
* invalid code
*/
CODE_40116(40116, "invalid code"),
/**
* 分组名字不合法 invalid button media_id size
*/
CODE_40117(40117, "分组名字不合法"),
/**
* media_id 大小不合法 invalid sub button media_id size
*/
CODE_40118(40118, "media_id 大小不合法"),
/**
* button 类型错误 invalid use button type
*/
CODE_40119(40119, "button 类型错误"),
/**
* 子 button 类型错误 invalid use sub button type
*/
CODE_40120(40120, "子 button 类型错误"),
/**
* 不合法的 media_id 类型 invalid media type in view_limited
*/
CODE_40121(40121, "不合法的 media_id 类型"),
/**
* invalid card quantity
*/
CODE_40122(40122, "invalid card quantity"),
/**
* invalid task_id
*/
CODE_40123(40123, "invalid task_id"),
/**
* too many custom field!
*/
CODE_40124(40124, "too many custom field!"),
/**
* 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写 invalid appsecret
*/
CODE_40125(40125, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"),
/**
* invalid text size
*/
CODE_40126(40126, "invalid text size"),
/**
* invalid user-card status! Hint: the card was given to user, but may be deleted or expired or set unavailable !
*/
CODE_40127(40127, "invalid user-card status! Hint: the card was given to user, but may be deleted or expired or set unavailable !"),
/**
* invalid media id! must be uploaded by api(cgi-bin/material/add_material)
*/
CODE_40128(40128, "invalid media id! must be uploaded by api(cgi-bin/material/add_material)"),
/**
* invalid scene
*/
CODE_40129(40129, "invalid scene"),
/**
* invalid openid list size, at least two openid
*/
CODE_40130(40130, "invalid openid list size, at least two openid"),
/**
* out of limit of ticket
*/
CODE_40131(40131, "out of limit of ticket"),
/**
* 微信号不合法 invalid username
*/
CODE_40132(40132, "微信号不合法"),
/**
* invalid encryt data
*/
CODE_40133(40133, "invalid encryt data"),
/**
* invalid not supply bonus, can not change card_id which supply bonus to be not supply
*/
CODE_40135(40135, "invalid not supply bonus, can not change card_id which supply bonus to be not supply"),
/**
* invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity
*/
CODE_40136(40136, "invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity"),
/**
* 不支持的图片格式 invalid image format
*/
CODE_40137(40137, "不支持的图片格式"),
/**
* emphasis word can not be first neither remark
*/
CODE_40138(40138, "emphasis word can not be first neither remark"),
/**
* invalid sub merchant id
*/
CODE_40139(40139, "invalid sub merchant id"),
/**
* invalid sub merchant status
*/
CODE_40140(40140, "invalid sub merchant status"),
/**
* invalid image url
*/
CODE_40141(40141, "invalid image url"),
/**
* invalid sharecard parameters
*/
CODE_40142(40142, "invalid sharecard parameters"),
/**
* invalid least cost info, should be 0
*/
CODE_40143(40143, "invalid least cost info, should be 0"),
/**
* 1)maybe share_card_list.num or consume_share_self_num too big; 2)maybe card_id_list also has self-card_id;3)maybe card_id_list has many different card_id;4)maybe both consume_share_self_num and share_card_list.num bigger than 0
*/
CODE_40144(40144, "1)maybe share_card_list.num or consume_share_self_num too big; 2)maybe card_id_list also has self-card_id;3)maybe card_id_list has many different card_id;4)maybe both consume_share_self_num and share_card_list.num bigger than 0"),
/**
* invalid update! Can not both set PayCell and CenterCellInfo(include: center_title, center_sub_title, center_url).
*/
CODE_40145(40145, "invalid update! Can not both set PayCell and CenterCellInfo(include: center_title, center_sub_title, center_url)."),
/**
* invalid openid! card may be marked by other user!
*/
CODE_40146(40146, "invalid openid! card may be marked by other user!"),
/**
* invalid consume! Consume time overranging restricts.
*/
CODE_40147(40147, "invalid consume! Consume time overranging restricts."),
/**
* invalid friends card type
*/
CODE_40148(40148, "invalid friends card type"),
/**
* invalid use time limit
*/
CODE_40149(40149, "invalid use time limit"),
/**
* invalid card parameters
*/
CODE_40150(40150, "invalid card parameters"),
/**
* invalid card info, text/pic hit antispam
*/
CODE_40151(40151, "invalid card info, text/pic hit antispam"),
/**
* invalid group id
*/
CODE_40152(40152, "invalid group id"),
/**
* self consume cell for friends card must need verify code
*/
CODE_40153(40153, "self consume cell for friends card must need verify code"),
/**
* invalid voip parameters
*/
CODE_40154(40154, "invalid voip parameters"),
/**
* 请勿添加其他公众号的主页链接 please don't contain other home page url
*/
CODE_40155(40155, "请勿添加其他公众号的主页链接"),
/**
* invalid face recognize parameters
*/
CODE_40156(40156, "invalid face recognize parameters"),
/**
* invalid picture, has no face
*/
CODE_40157(40157, "invalid picture, has no face"),
/**
* invalid use_custom_code, need be false
*/
CODE_40158(40158, "invalid use_custom_code, need be false"),
/**
* invalid length for path, or the data is not json string
*/
CODE_40159(40159, "invalid length for path, or the data is not json string"),
/**
* invalid image file
*/
CODE_40160(40160, "invalid image file"),
/**
* image file not match
*/
CODE_40161(40161, "image file not match"),
/**
* invalid lifespan
*/
CODE_40162(40162, "invalid lifespan"),
/**
* oauth_code已使用 code been used
*/
CODE_40163(40163, "oauth_code已使用"),
/**
* invalid ip, not in whitelist
*/
CODE_40164(40164, "invalid ip, not in whitelist"),
/**
* invalid weapp pagepath
*/
CODE_40165(40165, "invalid weapp pagepath"),
/**
* invalid weapp appid
*/
CODE_40166(40166, "invalid weapp appid"),
/**
* there is no relation with plugin appid
*/
CODE_40167(40167, "there is no relation with plugin appid"),
/**
* unlinked weapp card
*/
CODE_40168(40168, "unlinked weapp card"),
/**
* invalid length for scene, or the data is not json string
*/
CODE_40169(40169, "invalid length for scene, or the data is not json string"),
/**
* args count exceed count limit
*/
CODE_40170(40170, "args count exceed count limit"),
/**
* product id can not empty and the length cannot exceed 32
*/
CODE_40171(40171, "product id can not empty and the length cannot exceed 32"),
/**
* can not have same product id
*/
CODE_40172(40172, "can not have same product id"),
/**
* there is no bind relation
*/
CODE_40173(40173, "there is no bind relation"),
/**
* not card user
*/
CODE_40174(40174, "not card user"),
/**
* invalid material id
*/
CODE_40175(40175, "invalid material id"),
/**
* invalid template id
*/
CODE_40176(40176, "invalid template id"),
/**
* invalid product id
*/
CODE_40177(40177, "invalid product id"),
/**
* invalid sign
*/
CODE_40178(40178, "invalid sign"),
/**
* Function is adjusted, rules are not allowed to add or update
*/
CODE_40179(40179, "Function is adjusted, rules are not allowed to add or update"),
/**
* invalid client tmp token
*/
CODE_40180(40180, "invalid client tmp token"),
/**
* invalid opengid
*/
CODE_40181(40181, "invalid opengid"),
/**
* invalid pack_id
*/
CODE_40182(40182, "invalid pack_id"),
/**
* invalid product_appid, product_appid should bind with wxa_appid
*/
CODE_40183(40183, "invalid product_appid, product_appid should bind with wxa_appid"),
/**
* invalid url path
*/
CODE_40184(40184, "invalid url path"),
/**
* invalid auth_token, or auth_token is expired
*/
CODE_40185(40185, "invalid auth_token, or auth_token is expired"),
/**
* invalid delegate
*/
CODE_40186(40186, "invalid delegate"),
/**
* invalid ip
*/
CODE_40187(40187, "invalid ip"),
/**
* invalid scope
*/
CODE_40188(40188, "invalid scope"),
/**
* invalid width
*/
CODE_40189(40189, "invalid width"),
/**
* invalid delegate time
*/
CODE_40190(40190, "invalid delegate time"),
/**
* invalid pic_url
*/
CODE_40191(40191, "invalid pic_url"),
/**
* invalid author in news
*/
CODE_40192(40192, "invalid author in news"),
/**
* invalid recommend length
*/
CODE_40193(40193, "invalid recommend length"),
/**
* illegal recommend
*/
CODE_40194(40194, "illegal recommend"),
/**
* invalid show_num
*/
CODE_40195(40195, "invalid show_num"),
/**
* invalid smartmsg media_id
*/
CODE_40196(40196, "invalid smartmsg media_id"),
/**
* invalid smartmsg media num
*/
CODE_40197(40197, "invalid smartmsg media num"),
/**
* invalid default msg article size, must be same as show_num
*/
CODE_40198(40198, "invalid default msg article size, must be same as show_num"),
/**
* 运单 ID 不存在,未查到运单 waybill_id not found
*/
CODE_40199(40199, "运单 ID 不存在,未查到运单"),
/**
* invalid account type
*/
CODE_40200(40200, "invalid account type"),
/**
* invalid check url
*/
CODE_40201(40201, "invalid check url"),
/**
* invalid check action
*/
CODE_40202(40202, "invalid check action"),
/**
* invalid check operator
*/
CODE_40203(40203, "invalid check operator"),
/**
* can not delete wash or rumor article
*/
CODE_40204(40204, "can not delete wash or rumor article"),
/**
* invalid check keywords string
*/
CODE_40205(40205, "invalid check keywords string"),
/**
* invalid check begin stamp
*/
CODE_40206(40206, "invalid check begin stamp"),
/**
* invalid check alive seconds
*/
CODE_40207(40207, "invalid check alive seconds"),
/**
* invalid check notify id
*/
CODE_40208(40208, "invalid check notify id"),
/**
* invalid check notify msg
*/
CODE_40209(40209, "invalid check notify msg"),
/**
* pages 中的path参数不存在或为空 invalid check wxa path
*/
CODE_40210(40210, "pages 中的path参数不存在或为空"),
/**
* invalid scope_data
*/
CODE_40211(40211, "invalid scope_data"),
/**
* paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2 invalid query
*/
CODE_40212(40212, "paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2"),
/**
* invalid href tag
*/
CODE_40213(40213, "invalid href tag"),
/**
* invalid href text
*/
CODE_40214(40214, "invalid href text"),
/**
* invalid image count
*/
CODE_40215(40215, "invalid image count"),
/**
* invalid desc
*/
CODE_40216(40216, "invalid desc"),
/**
* invalid video count
*/
CODE_40217(40217, "invalid video count"),
/**
* invalid video id
*/
CODE_40218(40218, "invalid video id"),
/**
* pages不存在或者参数为空 pages is empty
*/
CODE_40219(40219, "pages不存在或者参数为空"),
/**
* data_list is empty
*/
CODE_40220(40220, "data_list is empty"),
/**
* invalid Content-Encoding
*/
CODE_40221(40221, "invalid Content-Encoding"),
/**
* invalid request idc domain
*/
CODE_40222(40222, "invalid request idc domain"),
/**
* empty media cover, please check the media
*/
CODE_40229(40229, "媒体封面为空,请添加媒体封面"),
/**
* 缺少 access_token 参数 access_token missing
*/
CODE_41001(41001, "缺少 access_token 参数"),
/**
* 缺少 appid 参数 appid missing
*/
CODE_41002(41002, "缺少 appid 参数"),
/**
* 缺少 refresh_token 参数 refresh_token missing
*/
CODE_41003(41003, "缺少 refresh_token 参数"),
/**
* 缺少 secret 参数 appsecret missing
*/
CODE_41004(41004, "缺少 secret 参数"),
/**
* 缺少多媒体文件数据,传输素材无视频或图片内容 media data missing
*/
CODE_41005(41005, "缺少多媒体文件数据,传输素材无视频或图片内容"),
/**
* 缺少 media_id 参数 media_id missing
*/
CODE_41006(41006, "缺少 media_id 参数"),
/**
* 缺少子菜单数据 sub_menu data missing
*/
CODE_41007(41007, "缺少子菜单数据"),
/**
* 缺少 oauth code missing code
*/
CODE_41008(41008, "缺少 oauth code"),
/**
* 缺少 openid missing openid
*/
CODE_41009(41009, "缺少 openid"),
/**
* 缺失 url 参数 missing url
*/
CODE_41010(41010, "缺失 url 参数"),
/**
* missing required fields! please check document and request json!
*/
CODE_41011(41011, "missing required fields! please check document and request json!"),
/**
* missing card id
*/
CODE_41012(41012, "missing card id"),
/**
* missing code
*/
CODE_41013(41013, "missing code"),
/**
* missing ticket_class
*/
CODE_41014(41014, "missing ticket_class"),
/**
* missing show_time
*/
CODE_41015(41015, "missing show_time"),
/**
* missing screening_room
*/
CODE_41016(41016, "missing screening_room"),
/**
* missing seat_number
*/
CODE_41017(41017, "missing seat_number"),
/**
* missing component_appid
*/
CODE_41018(41018, "missing component_appid"),
/**
* missing platform_secret
*/
CODE_41019(41019, "missing platform_secret"),
/**
* missing platform_ticket
*/
CODE_41020(41020, "missing platform_ticket"),
/**
* missing component_access_token
*/
CODE_41021(41021, "missing component_access_token"),
/**
* missing "display" field
*/
CODE_41024(41024, "missing \"display\" field"),
/**
* poi_list empty
*/
CODE_41025(41025, "poi_list empty"),
/**
* missing image list info, text maybe empty
*/
CODE_41026(41026, "missing image list info, text maybe empty"),
/**
* missing voip call key
*/
CODE_41027(41027, "missing voip call key"),
/**
* invalid form id
*/
CODE_41028(41028, "invalid form id"),
/**
* form id used count reach limit
*/
CODE_41029(41029, "form id used count reach limit"),
/**
* page路径不正确,需要保证在现网版本小程序中存在,与app.json保持一致 invalid page
*/
CODE_41030(41030, "page路径不正确,需要保证在现网版本小程序中存在,与app.json保持一致"),
/**
* the form id have been blocked!
*/
CODE_41031(41031, "the form id have been blocked!"),
/**
* not allow to send message with submitted form id, for punishment
*/
CODE_41032(41032, "not allow to send message with submitted form id, for punishment"),
/**
* 只允许通过api创建的小程序使用 invaid register type
*/
CODE_41033(41033, "只允许通过api创建的小程序使用"),
/**
* not allow to send message with submitted form id, for punishment
*/
CODE_41034(41034, "not allow to send message with submitted form id, for punishment"),
/**
* not allow to send message with prepay id, for punishment
*/
CODE_41035(41035, "not allow to send message with prepay id, for punishment"),
/**
* appid ad cid
*/
CODE_41036(41036, "appid ad cid"),
/**
* appid ad_mch_appid
*/
CODE_41037(41037, "appid ad_mch_appid"),
/**
* appid pos_type
*/
CODE_41038(41038, "appid pos_type"),
/**
* access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明 access_token expired
*/
CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"),
/**
* refresh_token 超时 refresh_token expired
*/
CODE_42002(42002, "refresh_token 超时"),
/**
* oauth_code 超时 code expired
*/
CODE_42003(42003, "oauth_code 超时"),
/**
* plugin token expired
*/
CODE_42004(42004, "plugin token expired"),
/**
* api usage expired
*/
CODE_42005(42005, "api usage expired"),
/**
* component_access_token expired
*/
CODE_42006(42006, "component_access_token expired"),
/**
* 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权 access_token and refresh_token exception
*/
CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"),
/**
* voip call key expired
*/
CODE_42008(42008, "voip call key expired"),
/**
* client tmp token expired
*/
CODE_42009(42009, "client tmp token expired"),
/**
* 需要 GET 请求 require GET method
*/
CODE_43001(43001, "需要 GET 请求"),
/**
* 需要 POST 请求 require POST method
*/
CODE_43002(43002, "需要 POST 请求"),
/**
* 需要 HTTPS 请求 require https
*/
CODE_43003(43003, "需要 HTTPS 请求"),
/**
* 需要接收者关注 require subscribe
*/
CODE_43004(43004, "需要接收者关注"),
/**
* 需要好友关系 require friend relations
*/
CODE_43005(43005, "需要好友关系"),
/**
* require not block
*/
CODE_43006(43006, "require not block"),
/**
* require bizuser authorize
*/
CODE_43007(43007, "require bizuser authorize"),
/**
* require biz pay auth
*/
CODE_43008(43008, "require biz pay auth"),
/**
* can not use custom code, need authorize
*/
CODE_43009(43009, "can not use custom code, need authorize"),
/**
* can not use balance, need authorize
*/
CODE_43010(43010, "can not use balance, need authorize"),
/**
* can not use bonus, need authorize
*/
CODE_43011(43011, "can not use bonus, need authorize"),
/**
* can not use custom url, need authorize
*/
CODE_43012(43012, "can not use custom url, need authorize"),
/**
* can not use shake card, need authorize
*/
CODE_43013(43013, "can not use shake card, need authorize"),
/**
* require check agent
*/
CODE_43014(43014, "require check agent"),
/**
* require authorize by wechat team to use this function!
*/
CODE_43015(43015, "require authorize by wechat team to use this function!"),
/**
* 小程序未认证 require verify
*/
CODE_43016(43016, "小程序未认证"),
/**
* require location id!
*/
CODE_43017(43017, "require location id!"),
/**
* code has no been mark!
*/
CODE_43018(43018, "code has no been mark!"),
/**
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | true |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxRuntimeException.java | package me.chanjar.weixin.common.error;
/**
* WxJava专用的runtime exception.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-09-26
*/
public class WxRuntimeException extends RuntimeException {
private static final long serialVersionUID = 4881698471192264412L;
public WxRuntimeException(Throwable e) {
super(e);
}
public WxRuntimeException(String msg) {
super(msg);
}
public WxRuntimeException(String msg, Throwable e) {
super(msg, e);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/WxRedisOps.java | package me.chanjar.weixin.common.redis;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
/**
* 微信Redis相关操作
* <p>
* 该接口不承诺稳定, 外部实现请继承{@link BaseWxRedisOps}
*
* @author Mario Luo
* @see BaseWxRedisOps 实现需要继承该类
* @see JedisWxRedisOps jedis实现
* @see RedissonWxRedisOps redisson实现
* @see RedisTemplateWxRedisOps redisTemplate实现
*/
public interface WxRedisOps {
String getValue(String key);
void setValue(String key, String value, int expire, TimeUnit timeUnit);
Long getExpire(String key);
void expire(String key, int expire, TimeUnit timeUnit);
Lock getLock(String key);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/JedisWxRedisOps.java | package me.chanjar.weixin.common.redis;
import com.github.jedis.lock.JedisLock;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.util.locks.JedisDistributedLock;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.util.Pool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
/**
* @author Mario Luo
*
* @deprecated 该类底层使用过时的8年不维护的 {@link JedisLock}组件,不可靠,不建议继续使用。请
* 使用:{@link RedisTemplateWxRedisOps}、{@link RedissonWxRedisOps} 替换
*/
@RequiredArgsConstructor
public class JedisWxRedisOps implements WxRedisOps {
private final Pool<Jedis> jedisPool;
@Override
public String getValue(String key) {
try (Jedis jedis = this.jedisPool.getResource()) {
return jedis.get(key);
}
}
@Override
public void setValue(String key, String value, int expire, TimeUnit timeUnit) {
try (Jedis jedis = this.jedisPool.getResource()) {
if (expire <= 0) {
jedis.set(key, value);
} else {
jedis.psetex(key, timeUnit.toMillis(expire), value);
}
}
}
@Override
public Long getExpire(String key) {
try (Jedis jedis = this.jedisPool.getResource()) {
return jedis.ttl(key);
}
}
@Override
public void expire(String key, int expire, TimeUnit timeUnit) {
try (Jedis jedis = this.jedisPool.getResource()) {
jedis.pexpire(key, timeUnit.toMillis(expire));
}
}
@Override
public Lock getLock(String key) {
return new JedisDistributedLock(jedisPool, key);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/RedissonWxRedisOps.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/RedissonWxRedisOps.java | package me.chanjar.weixin.common.redis;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RedissonClient;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
@RequiredArgsConstructor
public class RedissonWxRedisOps implements WxRedisOps {
private final RedissonClient redissonClient;
@Override
public String getValue(String key) {
Object value = redissonClient.getBucket(key).get();
return value == null ? null : value.toString();
}
@Override
public void setValue(String key, String value, int expire, TimeUnit timeUnit) {
if (expire <= 0) {
redissonClient.getBucket(key).set(value);
} else {
redissonClient.getBucket(key).set(value, expire, timeUnit);
}
}
@Override
public Long getExpire(String key) {
long expire = redissonClient.getBucket(key).remainTimeToLive();
if (expire > 0) {
expire = expire / 1000;
}
return expire;
}
@Override
public void expire(String key, int expire, TimeUnit timeUnit) {
redissonClient.getBucket(key).expire(expire, timeUnit);
}
@Override
public Lock getLock(String key) {
return redissonClient.getLock(key);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/BaseWxRedisOps.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/BaseWxRedisOps.java | package me.chanjar.weixin.common.redis;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
/**
* 微信redis操作基本类
* <p>
* 非内置实现redis相关操作, 请实现该类
*/
public abstract class BaseWxRedisOps implements WxRedisOps {
@Override
public String getValue(String key) {
throw new UnsupportedOperationException();
}
@Override
public void setValue(String key, String value, int expire, TimeUnit timeUnit) {
throw new UnsupportedOperationException();
}
@Override
public Long getExpire(String key) {
throw new UnsupportedOperationException();
}
@Override
public void expire(String key, int expire, TimeUnit timeUnit) {
throw new UnsupportedOperationException();
}
@Override
public Lock getLock(String key) {
throw new UnsupportedOperationException();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/RedisTemplateWxRedisOps.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/redis/RedisTemplateWxRedisOps.java | package me.chanjar.weixin.common.redis;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.util.locks.RedisTemplateSimpleDistributedLock;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
@RequiredArgsConstructor
public class RedisTemplateWxRedisOps implements WxRedisOps {
private final StringRedisTemplate redisTemplate;
@Override
public String getValue(String key) {
return redisTemplate.opsForValue().get(key);
}
@Override
public void setValue(String key, String value, int expire, TimeUnit timeUnit) {
if (expire <= 0) {
redisTemplate.opsForValue().set(key, value);
} else {
redisTemplate.opsForValue().set(key, value, expire, timeUnit);
}
}
@Override
public Long getExpire(String key) {
return redisTemplate.getExpire(key);
}
@Override
public void expire(String key, int expire, TimeUnit timeUnit) {
redisTemplate.expire(key, expire, timeUnit);
}
@Override
public Lock getLock(@NonNull String key) {
return new RedisTemplateSimpleDistributedLock(redisTemplate, key, 60 * 1000);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java | package me.chanjar.weixin.common.api;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* <pre>
* 默认消息重复检查器.
* 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒
* 替换类WxMessageInMemoryDuplicateCheckerSingleton
* </pre>
*
* @author Daniel Qian
*/
@Deprecated
public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker {
/**
* 一个消息ID在内存的过期时间:15秒.
*/
private final Long timeToLive;
/**
* 每隔多少周期检查消息ID是否过期:5秒.
*/
private final Long clearPeriod;
/**
* 消息id->消息时间戳的map.
*/
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<>();
/**
* 后台清理线程是否已经开启.
*/
private final AtomicBoolean backgroundProcessStarted = new AtomicBoolean(false);
/**
* 无参构造方法.
* <pre>
* 一个消息ID在内存的过期时间:15秒
* 每隔多少周期检查消息ID是否过期:5秒
* </pre>
*/
public WxMessageInMemoryDuplicateChecker() {
this.timeToLive = 15 * 1000L;
this.clearPeriod = 5 * 1000L;
}
/**
* 构造方法.
*
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
* @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
*/
public WxMessageInMemoryDuplicateChecker(Long timeToLive, Long clearPeriod) {
this.timeToLive = timeToLive;
this.clearPeriod = clearPeriod;
}
protected void checkBackgroundProcessStarted() {
if (this.backgroundProcessStarted.getAndSet(true)) {
return;
}
Thread t = new Thread(() -> {
try {
while (true) {
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
Long now = System.currentTimeMillis();
for (Map.Entry<String, Long> entry :
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
}
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
t.setDaemon(true);
t.start();
}
@Override
public boolean isDuplicate(String messageId) {
if (messageId == null) {
return false;
}
checkBackgroundProcessStarted();
Long timestamp = this.msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
return timestamp != null;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateChecker.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInRedisDuplicateChecker.java | package me.chanjar.weixin.common.api;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
/**
* 利用redis检查消息是否重复
*
*/
@RequiredArgsConstructor
public class WxMessageInRedisDuplicateChecker implements WxMessageDuplicateChecker {
/**
* 过期时间
*/
private int expire = 10;
private final Logger log = LoggerFactory.getLogger(getClass());
private final RedissonClient redissonClient;
/**
* messageId是否重复
*
* @param messageId messageId
* @return 是否
*/
@Override
public boolean isDuplicate(String messageId) {
RBucket<String> r = redissonClient.getBucket("wx:message:duplicate:check:" + messageId);
boolean setSuccess = r.trySet("1", expire, TimeUnit.SECONDS);
return !setSuccess;
}
public int getExpire() {
return expire;
}
public void setExpire(int expire) {
this.expire = expire;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java | package me.chanjar.weixin.common.api;
import lombok.experimental.UtilityClass;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static me.chanjar.weixin.common.error.WxMpErrorMsgEnum.*;
/**
* 微信开发所使用到的常量类.
*
* @author Daniel Qian & binarywang & Wang_Wong
*/
@UtilityClass
public class WxConsts {
/**
* access_token 相关错误代码
* <pre>
* 发生以下情况时尝试刷新access_token
* 40001 获取access_token时AppSecret错误,或者access_token无效
* 42001 access_token超时
* 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
* </pre>
*/
public static final List<Integer> ACCESS_TOKEN_ERROR_CODES = Arrays.asList(CODE_40001.getCode(),
CODE_40014.getCode(), CODE_42001.getCode());
/**
* 微信接口返回的参数errcode.
*/
public static final String ERR_CODE = "errcode";
/**
* 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型.
*/
@UtilityClass
public static class XmlMsgType {
public static final String TEXT = "text";
public static final String IMAGE = "image";
public static final String VOICE = "voice";
public static final String SHORTVIDEO = "shortvideo";
public static final String VIDEO = "video";
public static final String NEWS = "news";
public static final String MUSIC = "music";
public static final String LOCATION = "location";
public static final String LINK = "link";
public static final String EVENT = "event";
public static final String DEVICE_TEXT = "device_text";
public static final String DEVICE_EVENT = "device_event";
public static final String DEVICE_STATUS = "device_status";
public static final String HARDWARE = "hardware";
public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
public static final String UPDATE_TASKCARD = "update_taskcard";
public static final String UPDATE_BUTTON = "update_button";
}
/**
* 主动发送消息(即客服消息)的消息类型.
*/
@UtilityClass
public static class KefuMsgType {
/**
* 文本消息.
*/
public static final String TEXT = "text";
/**
* 图片消息.
*/
public static final String IMAGE = "image";
/**
* 语音消息.
*/
public static final String VOICE = "voice";
/**
* 视频消息.
*/
public static final String VIDEO = "video";
/**
* 音乐消息.
*/
public static final String MUSIC = "music";
/**
* 图文消息(点击跳转到外链).
*/
public static final String NEWS = "news";
/**
* 图文消息(点击跳转到图文消息页面).
*/
public static final String MPNEWS = "mpnews";
/**
* markdown消息.
* (目前仅支持markdown语法的子集,微工作台(原企业号)不支持展示markdown消息)
*/
public static final String MARKDOWN = "markdown";
/**
* 发送文件(CP专用).
*/
public static final String FILE = "file";
/**
* 文本卡片消息(CP专用).
*/
public static final String TEXTCARD = "textcard";
/**
* 卡券消息.
*/
public static final String WXCARD = "wxcard";
/**
* 转发到客服的消息.
*/
public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
/**
* 小程序卡片(要求小程序与公众号已关联).
*/
public static final String MINIPROGRAMPAGE = "miniprogrampage";
/**
* 任务卡片消息.
*/
public static final String TASKCARD = "taskcard";
/**
* 菜单消息.
*/
public static final String MSGMENU = "msgmenu";
/**
* 小程序通知消息.
*/
public static final String MINIPROGRAM_NOTICE = "miniprogram_notice";
/**
* 模板卡片消息.
*/
public static final String TEMPLATE_CARD = "template_card";
/**
* 发送图文消息(点击跳转到图文消息页面)使用通过 “发布” 系列接口得到的 article_id(草稿箱功能上线后不再支持客服接口中带 media_id 的 mpnews 类型的图文消息)
*/
public static final String MP_NEWS_ARTICLE = "mpnewsarticle";
}
/**
* 发送「学校通知」类型
* https://developer.work.weixin.qq.com/document/path/92321
*/
@UtilityClass
public static class SchoolContactMsgType {
/**
* 文本消息.
*/
public static final String TEXT = "text";
/**
* 图片消息.
*/
public static final String IMAGE = "image";
/**
* 语音消息.
*/
public static final String VOICE = "voice";
/**
* 视频消息.
*/
public static final String VIDEO = "video";
/**
* 文件消息
*/
public static final String FILE = "file";
/**
* 图文消息
*/
public static final String NEWS = "news";
/**
* 图文消息(mpnews)
*/
public static final String MPNEWS = "mpnews";
/**
* 小程序消息
*/
public static final String MINIPROGRAM = "miniprogram";
}
/**
* 企业微信模板卡片消息的卡片类型
*/
@UtilityClass
public static class TemplateCardType {
/**
* 文本通知型卡片
*/
public static final String TEXT_NOTICE = "text_notice";
/**
* 图文展示型卡片
*/
public static final String NEWS_NOTICE = "news_notice";
/**
* 按钮交互型卡片
*/
public static final String BUTTON_INTERACTION = "button_interaction";
/**
* 投票选择型卡片
*/
public static final String VOTE_INTERACTION = "vote_interaction";
/**
* 多项选择型卡片
*/
public static final String MULTIPLE_INTERACTION = "multiple_interaction";
}
/**
* 表示是否是保密消息,0表示否,1表示是,默认0.
*/
@UtilityClass
public static class KefuMsgSafe {
public static final String NO = "0";
public static final String YES = "1";
}
/**
* 群发消息的消息类型.
*/
@UtilityClass
public static class MassMsgType {
public static final String MPNEWS = "mpnews";
public static final String TEXT = "text";
public static final String VOICE = "voice";
public static final String IMAGE = "image";
public static final String IMAGES = "images";
public static final String MPVIDEO = "mpvideo";
}
/**
* 群发消息后微信端推送给服务器的反馈消息.
*/
@UtilityClass
public static class MassMsgStatus {
public static final String SEND_SUCCESS = "send success";
public static final String SEND_FAIL = "send fail";
public static final String ERR_10001 = "err(10001)";
public static final String ERR_20001 = "err(20001)";
public static final String ERR_20004 = "err(20004)";
public static final String ERR_20002 = "err(20002)";
public static final String ERR_20006 = "err(20006)";
public static final String ERR_20008 = "err(20008)";
public static final String ERR_20013 = "err(20013)";
public static final String ERR_22000 = "err(22000)";
public static final String ERR_21000 = "err(21000)";
public static final String ERR_30001 = "err(30001)";
public static final String ERR_30002 = "err(30002)";
public static final String ERR_30003 = "err(30003)";
public static final String ERR_40001 = "err(40001)";
public static final String ERR_40002 = "err(40002)";
/**
* 群发反馈消息代码所对应的文字描述.
*/
public static final Map<String, String> STATUS_DESC = new HashMap<>();
static {
STATUS_DESC.put(SEND_SUCCESS, "发送成功");
STATUS_DESC.put(SEND_FAIL, "发送失败");
STATUS_DESC.put(ERR_10001, "涉嫌广告");
STATUS_DESC.put(ERR_20001, "涉嫌政治");
STATUS_DESC.put(ERR_20004, "涉嫌社会");
STATUS_DESC.put(ERR_20002, "涉嫌色情");
STATUS_DESC.put(ERR_20006, "涉嫌违法犯罪");
STATUS_DESC.put(ERR_20008, "涉嫌欺诈");
STATUS_DESC.put(ERR_20013, "涉嫌版权");
STATUS_DESC.put(ERR_22000, "涉嫌互推_互相宣传");
STATUS_DESC.put(ERR_21000, "涉嫌其他");
STATUS_DESC.put(ERR_30001, "原创校验出现系统错误且用户选择了被判为转载就不群发");
STATUS_DESC.put(ERR_30002, "原创校验被判定为不能群发");
STATUS_DESC.put(ERR_30003, "原创校验被判定为转载文且用户选择了被判为转载就不群发");
STATUS_DESC.put(ERR_40001, "管理员拒绝");
STATUS_DESC.put(ERR_40002, "管理员30分钟内无响应,超时");
}
}
/**
* 微信端推送过来的事件类型.
*/
@UtilityClass
public static class EventType {
public static final String SUBSCRIBE = "subscribe";
public static final String UNSUBSCRIBE = "unsubscribe";
public static final String SCAN = "SCAN";
public static final String LOCATION = "LOCATION";
public static final String CLICK = "CLICK";
public static final String VIEW = "VIEW";
public static final String MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH";
public static final String SYS_APPROVAL_CHANGE = "sys_approval_change";
/**
* 扫码推事件的事件推送
*/
public static final String SCANCODE_PUSH = "scancode_push";
/**
* 扫码推事件且弹出“消息接收中”提示框的事件推送.
*/
public static final String SCANCODE_WAITMSG = "scancode_waitmsg";
/**
* 弹出系统拍照发图的事件推送.
*/
public static final String PIC_SYSPHOTO = "pic_sysphoto";
/**
* 弹出拍照或者相册发图的事件推送.
*/
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
/**
* 弹出微信相册发图器的事件推送.
*/
public static final String PIC_WEIXIN = "pic_weixin";
/**
* 弹出地理位置选择器的事件推送.
*/
public static final String LOCATION_SELECT = "location_select";
/**
* 授权用户资料变更事件
* 1、 当部分用户的资料存在风险时,平台会对用户资料进行清理,并通过消息推送服务器通知最近30天授权过的公众号开发者,我们建议开发者留意响应该事件,及时主动更新或清理用户的头像及昵称,降低风险。
* 2、 当用户撤回授权信息时,平台会通过消息推送服务器通知给公众号开发者,请开发者注意及时删除用户信息。
*/
public static final String USER_INFO_MODIFIED = "user_info_modified";
/**
* 用户撤回授权事件
*/
public static final String USER_AUTHORIZATION_REVOKE = "user_authorization_revoke";
/**
* 群发模板回调事件
*/
public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH";
/**
* 微信小店 订单付款通知.
*/
public static final String MERCHANT_ORDER = "merchant_order";
/**
* 卡券事件:卡券通过审核
*/
public static final String CARD_PASS_CHECK = "card_pass_check";
/**
* 卡券事件:卡券未通过审核
*/
public static final String CARD_NOT_PASS_CHECK = "card_not_pass_check";
/**
* 卡券事件:用户领取卡券
*/
public static final String CARD_USER_GET_CARD = "user_get_card";
/**
* 卡券事件:用户转赠卡券
*/
public static final String CARD_USER_GIFTING_CARD = "user_gifting_card";
/**
* 异步安全校验事件
*/
public static final String WXA_MEDIA_CHECK = "wxa_media_check";
/**
* 卡券事件:用户核销卡券
*/
public static final String CARD_USER_CONSUME_CARD = "user_consume_card";
/**
* 卡券事件:用户通过卡券的微信买单完成时推送
*/
public static final String CARD_USER_PAY_FROM_PAY_CELL = "user_pay_from_pay_cell";
/**
* 卡券事件:用户提交会员卡开卡信息
*/
public static final String CARD_SUBMIT_MEMBERCARD_USER_INFO = "submit_membercard_user_info";
/**
* 卡券事件:用户打开查看卡券
*/
public static final String CARD_USER_VIEW_CARD = "user_view_card";
/**
* 卡券事件:用户删除卡券
*/
public static final String CARD_USER_DEL_CARD = "user_del_card";
/**
* 卡券事件:用户在卡券里点击查看公众号进入会话时(需要用户已经关注公众号)
*/
public static final String CARD_USER_ENTER_SESSION_FROM_CARD = "user_enter_session_from_card";
/**
* 卡券事件:当用户的会员卡积分余额发生变动时
*/
public static final String CARD_UPDATE_MEMBER_CARD = "update_member_card";
/**
* 卡券事件:当某个card_id的初始库存数大于200且当前库存小于等于100时,用户尝试领券会触发发送事件给商户,事件每隔12h发送一次
*/
public static final String CARD_SKU_REMIND = "card_sku_remind";
/**
* 卡券事件:当商户朋友的券券点发生变动时
*/
public static final String CARD_PAY_ORDER = "card_pay_order";
/**
* 小程序审核事件:审核通过
*/
public static final String WEAPP_AUDIT_SUCCESS = "weapp_audit_success";
/**
* 小程序审核事件:审核不通过
*/
public static final String WEAPP_AUDIT_FAIL = "weapp_audit_fail";
/**
* 小程序审核事件:审核延后
*/
public static final String WEAPP_AUDIT_DELAY = "weapp_audit_delay";
/**
* 小程序自定义交易组件支付通知
*/
public static final String OPEN_PRODUCT_ORDER_PAY = "open_product_order_pay";
/**
* 点击菜单跳转小程序的事件推送
*/
public static final String VIEW_MINIPROGRAM = "view_miniprogram";
/**
* 订阅通知事件:用户操作订阅通知弹窗
*/
public static final String SUBSCRIBE_MSG_POPUP_EVENT = "subscribe_msg_popup_event";
/**
* 订阅通知事件:用户管理订阅通知
*/
public static final String SUBSCRIBE_MSG_CHANGE_EVENT = "subscribe_msg_change_event";
/**
* 订阅通知事件:发送订阅通知回调
*/
public static final String SUBSCRIBE_MSG_SENT_EVENT = "subscribe_msg_sent_event";
/**
* 名称审核事件
*/
public static final String WXA_NICKNAME_AUDIT = "wxa_nickname_audit";
/**
* 小程序违规记录事件
*/
public static final String WXA_ILLEGAL_RECORD = "wxa_illegal_record";
/**
* 小程序申诉记录推送
*/
public static final String WXA_APPEAL_RECORD = "wxa_appeal_record";
/**
* 隐私权限审核结果推送
*/
public static final String WXA_PRIVACY_APPLY = "wxa_privacy_apply";
/**
* 类目审核结果事件推送
*/
public static final String WXA_CATEGORY_AUDIT = "wxa_category_audit";
/**
* 小程序微信认证支付成功事件
*/
public static final String WX_VERIFY_PAY_SUCC = "wx_verify_pay_succ";
/**
* 小程序微信认证派单事件
*/
public static final String WX_VERIFY_DISPATCH = "wx_verify_dispatch";
/**
* 提醒需要上传发货信息事件:曾经发过货的小程序,订单超过48小时未发货时
*/
public static final String TRADE_MANAGE_REMIND_SHIPPING = "trade_manage_remind_shipping";
/**
* 订单完成发货时、订单结算时
*/
public static final String TRADE_MANAGE_ORDER_SETTLEMENT = "trade_manage_order_settlement";
}
/**
* 上传多媒体(临时素材)文件的类型.
*/
public static class MediaFileType {
public static final String IMAGE = "image";
public static final String VOICE = "voice";
public static final String VIDEO = "video";
public static final String THUMB = "thumb";
public static final String FILE = "file";
}
/**
* 自定义菜单的按钮类型.
*/
@UtilityClass
public static class MenuButtonType {
/**
* 点击推事件.
*/
public static final String CLICK = "click";
/**
* 跳转URL.
*/
public static final String VIEW = "view";
/**
* 跳转到小程序.
*/
public static final String MINIPROGRAM = "miniprogram";
/**
* 扫码推事件.
*/
public static final String SCANCODE_PUSH = "scancode_push";
/**
* 扫码推事件且弹出“消息接收中”提示框.
*/
public static final String SCANCODE_WAITMSG = "scancode_waitmsg";
/**
* 弹出系统拍照发图.
*/
public static final String PIC_SYSPHOTO = "pic_sysphoto";
/**
* 弹出拍照或者相册发图.
*/
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
/**
* 弹出微信相册发图器.
*/
public static final String PIC_WEIXIN = "pic_weixin";
/**
* 弹出地理位置选择器.
*/
public static final String LOCATION_SELECT = "location_select";
/**
* 下发消息(除文本消息).
*/
public static final String MEDIA_ID = "media_id";
/**
* 跳转图文消息URL.
*/
public static final String VIEW_LIMITED = "view_limited";
}
/**
* oauth2网页授权的scope.
*/
@UtilityClass
public static class OAuth2Scope {
/**
* 不弹出授权页面,直接跳转,只能获取用户openid.
*/
public static final String SNSAPI_BASE = "snsapi_base";
/**
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息.
*/
public static final String SNSAPI_USERINFO = "snsapi_userinfo";
/**
* 手动授权,可获取成员的详细信息,包含手机、邮箱。只适用于企业微信或企业号.
*/
public static final String SNSAPI_PRIVATEINFO = "snsapi_privateinfo";
}
/**
* 网页应用登录授权作用域.
*/
@UtilityClass
public static class QrConnectScope {
public static final String SNSAPI_LOGIN = "snsapi_login";
}
/**
* 永久素材类型.
*/
@UtilityClass
public static class MaterialType {
public static final String NEWS = "news";
public static final String VOICE = "voice";
public static final String IMAGE = "image";
public static final String VIDEO = "video";
}
/**
* 网络检测入参.
*/
@UtilityClass
public static class NetCheckArgs {
public static final String ACTIONDNS = "dns";
public static final String ACTIONPING = "ping";
public static final String ACTIONALL = "all";
public static final String OPERATORUNICOM = "UNICOM";
public static final String OPERATORCHINANET = "CHINANET";
public static final String OPERATORCAP = "CAP";
public static final String OPERATORDEFAULT = "DEFAULT";
}
/**
* appId 类型
*/
@UtilityClass
public static class AppIdType {
/**
* 公众号appId类型
*/
public static final String MP_TYPE = "mp";
/**
* 小程序appId类型
*/
public static final String MINI_TYPE = "mini";
}
/**
* 新建文章类型
*/
@UtilityClass
public static class ArticleType {
/**
* 图文消息
*/
public static final String NEWS = "news";
/**
* 图片消息
*/
public static final String NEWS_PIC = "newspic";
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java | package me.chanjar.weixin.common.api;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* WxErrorException处理器.
*
* @author Daniel Qian
*/
public interface WxErrorExceptionHandler {
void handle(WxErrorException e);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingleton.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateCheckerSingleton.java | package me.chanjar.weixin.common.api;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author jiangby
* @version 1.0
* <p>
* 消息去重,记录消息ID首次出现时的时间戳,
* 15S后定时任务触发时废除该记录消息ID
* </p>
* created on 2022/5/26 1:32
*/
@Slf4j
public class WxMessageInMemoryDuplicateCheckerSingleton implements WxMessageDuplicateChecker {
/**
* 一个消息ID在内存的过期时间:15秒.
*/
private static final Long TIME_TO_LIVE = 15L;
/**
* 每隔多少周期检查消息ID是否过期:5秒.
*/
private static final Long CLEAR_PERIOD = 5L;
/**
* 线程池
*/
private static final ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(1,
new ThreadFactoryBuilder().setNameFormat("wxMessage-memory-pool-%d").setDaemon(true).build(), new ThreadPoolExecutor.AbortPolicy());
/**
* 消息id->消息时间戳的map.
*/
private static final ConcurrentHashMap<String, Long> MSG_ID_2_TIMESTAMP = new ConcurrentHashMap<>();
static {
SCHEDULED_THREAD_POOL_EXECUTOR.scheduleAtFixedRate(() -> {
try {
Long now = System.currentTimeMillis();
MSG_ID_2_TIMESTAMP.entrySet().removeIf(entry -> now - entry.getValue() > TIME_TO_LIVE * 1000);
} catch (Exception ex) {
log.error("重复消息去重任务出现异常", ex);
}
}, 1, CLEAR_PERIOD, TimeUnit.SECONDS);
}
/**
* 私有化构造方法,避免外部调用
*/
private WxMessageInMemoryDuplicateCheckerSingleton() {
}
/**
* 获取单例
*
* @return 单例对象
*/
public static WxMessageInMemoryDuplicateCheckerSingleton getInstance() {
return WxMessageInnerClass.CHECKER_SINGLETON;
}
/**
* 内部类实现单例
*/
private static class WxMessageInnerClass {
static final WxMessageInMemoryDuplicateCheckerSingleton CHECKER_SINGLETON = new WxMessageInMemoryDuplicateCheckerSingleton();
}
/**
* messageId是否重复
*
* @param messageId messageId
* @return 是否
*/
@Override
public boolean isDuplicate(String messageId) {
if (messageId == null) {
return false;
}
Long timestamp = MSG_ID_2_TIMESTAMP.putIfAbsent(messageId, System.currentTimeMillis());
return timestamp != null;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java | package me.chanjar.weixin.common.api;
/**
* <pre>
* 消息重复检查器.
* 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次
* </pre>
*
* @author Daniel Qian
*/
public interface WxMessageDuplicateChecker {
/**
* 判断消息是否重复.
* <h2>公众号的排重方式</h2>
*
* <p>普通消息:关于重试的消息排重,推荐使用msgid排重。<a href="http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html">文档参考</a>。</p>
* <p>事件消息:关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。<a href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html">文档参考</a></p>
*
* <h2>企业号的排重方式</h2>
* <p>官方文档完全没有写,参照公众号的方式排重。</p>
* <p>或者可以采取更简单的方式,如果有MsgId就用MsgId排重,如果没有就用FromUserName+CreateTime排重</p>
*
* @param messageId messageId需要根据上面讲的方式构造
* @return 如果是重复消息,返回true,否则返回false
*/
boolean isDuplicate(String messageId);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/TooManyActiveSessionsException.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/TooManyActiveSessionsException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.chanjar.weixin.common.session;
/**
* An exception that indicates the maximum number of active sessions has been
* reached and the server is refusing to create any new sessions.
*
* @author Daniel Qian
*/
public class TooManyActiveSessionsException
extends IllegalStateException {
private static final long serialVersionUID = 1L;
/**
* The maximum number of active sessions the server will tolerate.
*/
private final int maxActiveSessions;
/**
* Creates a new TooManyActiveSessionsException.
*
* @param message A description for the exception.
* @param maxActive The maximum number of active sessions allowed by the
* session manager.
*/
public TooManyActiveSessionsException(String message,
int maxActive) {
super(message);
this.maxActiveSessions = maxActive;
}
/**
* Gets the maximum number of sessions allowed by the session manager.
*
* @return The maximum number of sessions allowed by the session manager.
*/
public int getMaxActiveSessions() {
return this.maxActiveSessions;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSession.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSession.java | package me.chanjar.weixin.common.session;
import java.util.Enumeration;
/**
* @author Daniel Qian
*/
public interface WxSession {
Object getAttribute(String name);
Enumeration<String> getAttributeNames();
void setAttribute(String name, Object value);
void removeAttribute(String name);
void invalidate();
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java | package me.chanjar.weixin.common.session;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import me.chanjar.weixin.common.util.res.StringManager;
/**
* @author Daniel Qian
*/
public class StandardSession implements WxSession, InternalSession {
/**
* The string manager for this package.
*/
protected static final StringManager SM = StringManager.getManager(Constants.PACKAGE);
/**
* Type array.
*/
private static final String[] EMPTY_ARRAY = new String[0];
protected Map<String, Object> attributes = new ConcurrentHashMap<>();
/**
* The session identifier of this Session.
*/
protected String id = null;
/**
* Flag indicating whether this session is valid or not.
*/
protected volatile boolean isValid = false;
/**
* We are currently processing a session expiration, so bypass
* certain IllegalStateException tests. NOTE: This value is not
* included in the serialized version of this object.
*/
protected transient volatile boolean expiring = false;
/**
* The Manager with which this Session is associated.
*/
protected transient InternalSessionManager manager = null;
// ------------------------------ InternalSession
/**
* The time this session was created, in milliseconds since midnight,
* January 1, 1970 GMT.
*/
protected long creationTime = 0L;
/**
* The current accessed time for this session.
*/
protected volatile long thisAccessedTime = this.creationTime;
/**
* The default maximum inactive interval for Sessions created by
* this Manager.
*/
protected int maxInactiveInterval = 30 * 60;
/**
* The facade associated with this session. NOTE: This value is not
* included in the serialized version of this object.
*/
protected transient StandardSessionFacade facade = null;
/**
* The access count for this session.
*/
protected transient AtomicInteger accessCount = null;
public StandardSession(InternalSessionManager manager) {
this.manager = manager;
this.accessCount = new AtomicInteger();
}
@Override
public Object getAttribute(String name) {
if (!isValidInternal()) {
throw new IllegalStateException
(SM.getString("sessionImpl.getAttribute.ise"));
}
if (name == null) {
return null;
}
return this.attributes.get(name);
}
@Override
public Enumeration<String> getAttributeNames() {
if (!isValidInternal()) {
throw new IllegalStateException(SM.getString("sessionImpl.getAttributeNames.ise"));
}
Set<String> names = new HashSet<>();
names.addAll(this.attributes.keySet());
return Collections.enumeration(names);
}
@Override
public void setAttribute(String name, Object value) {
// Name cannot be null
if (name == null) {
throw new IllegalArgumentException(SM.getString("sessionImpl.setAttribute.namenull"));
}
// Null value is the same as removeAttribute()
if (value == null) {
removeAttribute(name);
return;
}
// Validate our current state
if (!isValidInternal()) {
throw new IllegalStateException(SM.getString("sessionImpl.setAttribute.ise", getIdInternal()));
}
this.attributes.put(name, value);
}
@Override
public void removeAttribute(String name) {
removeAttributeInternal(name);
}
@Override
public void invalidate() {
if (!isValidInternal()) {
throw new IllegalStateException(SM.getString("sessionImpl.invalidate.ise"));
}
// Cause this session to expire
expire();
}
@Override
public WxSession getSession() {
if (this.facade == null) {
this.facade = new StandardSessionFacade(this);
}
return this.facade;
}
/**
* Return the <code>isValid</code> flag for this session without any expiration
* check.
*/
protected boolean isValidInternal() {
return this.isValid;
}
@Override
public boolean isValid() {
if (!this.isValid) {
return false;
}
if (this.expiring) {
return true;
}
if (this.accessCount.get() > 0) {
return true;
}
if (this.maxInactiveInterval > 0) {
long timeNow = System.currentTimeMillis();
int timeIdle;
timeIdle = (int) ((timeNow - this.thisAccessedTime) / 1000L);
if (timeIdle >= this.maxInactiveInterval) {
expire();
}
}
return this.isValid;
}
/**
* Set the <code>isValid</code> flag for this session.
*
* @param isValid The new value for the <code>isValid</code> flag
*/
@Override
public void setValid(boolean isValid) {
this.isValid = isValid;
}
@Override
public String getIdInternal() {
return this.id;
}
protected void removeAttributeInternal(String name) {
// Avoid NPE
if (name == null) {
return;
}
// Remove this attribute from our collection
this.attributes.remove(name);
}
@Override
public void expire() {
// Check to see if session has already been invalidated.
// Do not check expiring at this point as expire should not return until
// isValid is false
if (!this.isValid) {
return;
}
synchronized (this) {
// Check again, now we are inside the sync so this code only runs once
// Double check locking - isValid needs to be volatile
// The check of expiring is to ensure that an infinite loop is not
// entered as per bug 56339
if (this.expiring || !this.isValid) {
return;
}
if (this.manager == null) {
return;
}
// Mark this session as "being expired"
this.expiring = true;
this.accessCount.set(0);
// Remove this session from our manager's active sessions
this.manager.remove(this, true);
// We have completed expire of this session
setValid(false);
this.expiring = false;
// Unbind any objects associated with this session
String[] keys = keys();
for (String key : keys) {
removeAttributeInternal(key);
}
}
}
@Override
public void access() {
this.thisAccessedTime = System.currentTimeMillis();
this.accessCount.incrementAndGet();
}
@Override
public void endAccess() {
this.thisAccessedTime = System.currentTimeMillis();
this.accessCount.decrementAndGet();
}
@Override
public void setCreationTime(long time) {
this.creationTime = time;
this.thisAccessedTime = time;
}
@Override
public void setMaxInactiveInterval(int interval) {
this.maxInactiveInterval = interval;
}
@Override
public void setId(String id) {
if ((this.id != null) && (this.manager != null)) {
this.manager.remove(this);
}
this.id = id;
if (this.manager != null) {
this.manager.add(this);
}
}
/**
* Return the names of all currently defined session attributes
* as an array of Strings. If there are no defined attributes, a
* zero-length array is returned.
*/
protected String[] keys() {
return this.attributes.keySet().toArray(EMPTY_ARRAY);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof StandardSession)) {
return false;
}
StandardSession session = (StandardSession) o;
if (this.creationTime != session.creationTime) {
return false;
}
if (this.expiring != session.expiring) {
return false;
}
if (this.isValid != session.isValid) {
return false;
}
if (this.maxInactiveInterval != session.maxInactiveInterval) {
return false;
}
if (this.thisAccessedTime != session.thisAccessedTime) {
return false;
}
if (this.accessCount.get() != session.accessCount.get()) {
return false;
}
if (!this.attributes.equals(session.attributes)) {
return false;
}
if (!this.facade.equals(session.facade)) {
return false;
}
return this.id.equals(session.id) && this.manager.equals(session.manager);
}
@Override
public int hashCode() {
int result = this.attributes.hashCode();
result = 31 * result + this.id.hashCode();
result = 31 * result + (this.isValid ? 1 : 0);
result = 31 * result + (this.expiring ? 1 : 0);
result = 31 * result + this.manager.hashCode();
result = 31 * result + (int) (this.creationTime ^ (this.creationTime >>> 32));
result = 31 * result + (int) (this.thisAccessedTime ^ (this.thisAccessedTime >>> 32));
result = 31 * result + this.maxInactiveInterval;
result = 31 * result + this.facade.hashCode();
result = 31 * result + this.accessCount.hashCode();
return result;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionFacade.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionFacade.java | package me.chanjar.weixin.common.session;
import java.util.Enumeration;
/**
* @author Daniel Qian
*/
public class StandardSessionFacade implements WxSession {
/**
* Wrapped session object.
*/
private WxSession session = null;
public StandardSessionFacade(StandardSession session) {
this.session = session;
}
public InternalSession getInternalSession() {
return (InternalSession) this.session;
}
@Override
public Object getAttribute(String name) {
return this.session.getAttribute(name);
}
@Override
public Enumeration<String> getAttributeNames() {
return this.session.getAttributeNames();
}
@Override
public void setAttribute(String name, Object value) {
this.session.setAttribute(name, value);
}
@Override
public void removeAttribute(String name) {
this.session.removeAttribute(name);
}
@Override
public void invalidate() {
this.session.invalidate();
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java | package me.chanjar.weixin.common.session;
import me.chanjar.weixin.common.util.res.StringManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* 基于内存的session manager.
*
* @author Daniel Qian
*/
public class StandardSessionManager implements WxSessionManager, InternalSessionManager {
protected static final StringManager SM = StringManager.getManager(Constants.PACKAGE);
/**
* The descriptive name of this Manager implementation (for logging).
*/
private static final String name = "SessionManagerImpl";
protected final Logger log = LoggerFactory.getLogger(StandardSessionManager.class);
private final Object maxActiveUpdateLock = new Object();
/**
* 后台清理线程是否已经开启
*/
private final AtomicBoolean backgroundProcessStarted = new AtomicBoolean(false);
// -------------------------------------- InternalSessionManager
/**
* The set of currently active Sessions for this Manager, keyed by
* session identifier.
*/
protected Map<String, InternalSession> sessions = new ConcurrentHashMap<>();
/**
* The maximum number of active Sessions allowed, or -1 for no limit.
*/
protected int maxActiveSessions = -1;
/**
* Number of session creations that failed due to maxActiveSessions.
*/
protected int rejectedSessions = 0;
/**
* The default maximum inactive interval for Sessions created by
* this Manager.
*/
protected int maxInactiveInterval = 30 * 60;
/**
* Number of sessions created by this manager
*/
protected long sessionCounter = 0;
protected volatile int maxActive = 0;
/**
* Processing time during session expiration.
*/
protected long processingTime = 0;
/**
* Frequency of the session expiration, and related manager operations.
* Manager operations will be done once for the specified amount of
* backgrondProcess calls (ie, the lower the amount, the most often the
* checks will occur).
*/
protected int processExpiresFrequency = 6;
/**
* background processor delay in seconds
*/
protected int backgroundProcessorDelay = 10;
/**
* Iteration count for background processing.
*/
private int count = 0;
@Override
public WxSession getSession(String sessionId) {
return getSession(sessionId, true);
}
@Override
public WxSession getSession(String sessionId, boolean create) {
if (sessionId == null) {
throw new IllegalStateException
(SM.getString("sessionManagerImpl.getSession.ise"));
}
InternalSession session = findSession(sessionId);
if ((session != null) && !session.isValid()) {
session = null;
}
if (session != null) {
session.access();
return session.getSession();
}
// Create a new session if requested and the response is not committed
if (!create) {
return null;
}
session = createSession(sessionId);
if (session == null) {
return null;
}
session.access();
return session.getSession();
}
@Override
public void remove(InternalSession session) {
remove(session, false);
}
@Override
public void remove(InternalSession session, boolean update) {
if (session.getIdInternal() != null) {
this.sessions.remove(session.getIdInternal());
}
}
@Override
public InternalSession findSession(String id) {
if (id == null) {
return null;
}
return this.sessions.get(id);
}
@Override
public InternalSession createSession(String sessionId) {
if (sessionId == null) {
throw new IllegalStateException
(SM.getString("sessionManagerImpl.createSession.ise"));
}
if ((this.maxActiveSessions >= 0) &&
(getActiveSessions() >= this.maxActiveSessions)) {
this.rejectedSessions++;
throw new TooManyActiveSessionsException(
SM.getString("sessionManagerImpl.createSession.tmase"),
this.maxActiveSessions);
}
// Recycle or create a Session instance
InternalSession session = createEmptySession();
// Initialize the properties of the new session and return it
session.setValid(true);
session.setCreationTime(System.currentTimeMillis());
session.setMaxInactiveInterval(this.maxInactiveInterval);
session.setId(sessionId);
this.sessionCounter++;
return session;
}
@Override
public int getActiveSessions() {
return this.sessions.size();
}
@Override
public InternalSession createEmptySession() {
return (getNewSession());
}
/**
* Get new session class to be used in the doLoad() method.
*/
protected InternalSession getNewSession() {
return new StandardSession(this);
}
@Override
public void add(InternalSession session) {
// 当第一次有session创建的时候,开启session清理线程
if (!this.backgroundProcessStarted.getAndSet(true)) {
Thread t = new Thread(() -> {
while (true) {
try {
// 每秒清理一次
Thread.sleep(StandardSessionManager.this.backgroundProcessorDelay * 1000L);
backgroundProcess();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
StandardSessionManager.this.log.error("SessionManagerImpl.backgroundProcess error", e);
}
}
});
t.setDaemon(true);
t.start();
}
this.sessions.put(session.getIdInternal(), session);
int size = getActiveSessions();
if (size > this.maxActive) {
synchronized (this.maxActiveUpdateLock) {
if (size > this.maxActive) {
this.maxActive = size;
}
}
}
}
/**
* Return the set of active Sessions associated with this Manager.
* If this Manager has no active Sessions, a zero-length array is returned.
*/
@Override
public InternalSession[] findSessions() {
return this.sessions.values().toArray(new InternalSession[0]);
}
@Override
public void backgroundProcess() {
this.count = (this.count + 1) % this.processExpiresFrequency;
if (this.count == 0) {
processExpires();
}
}
/**
* Invalidate all sessions that have expired.
*/
public void processExpires() {
long timeNow = System.currentTimeMillis();
InternalSession sessions[] = findSessions();
int expireHere = 0;
if (this.log.isDebugEnabled()) {
this.log.debug("Start expire sessions {} at {} sessioncount {}", getName(), timeNow, sessions.length);
}
for (InternalSession session : sessions) {
if (session != null && !session.isValid()) {
expireHere++;
}
}
long timeEnd = System.currentTimeMillis();
if (this.log.isDebugEnabled()) {
this.log.debug("End expire sessions {} processingTime {} expired sessions: {}", getName(), timeEnd - timeNow, expireHere);
}
this.processingTime += timeEnd - timeNow;
}
@Override
public void setMaxInactiveInterval(int interval) {
this.maxInactiveInterval = interval;
}
/**
* Set the manager checks frequency.
*
* @param processExpiresFrequency the new manager checks frequency
*/
@Override
public void setProcessExpiresFrequency(int processExpiresFrequency) {
if (processExpiresFrequency <= 0) {
return;
}
this.processExpiresFrequency = processExpiresFrequency;
}
@Override
public void setBackgroundProcessorDelay(int backgroundProcessorDelay) {
this.backgroundProcessorDelay = backgroundProcessorDelay;
}
/**
* Return the descriptive short name of this Manager implementation.
*/
public String getName() {
return name;
}
/**
* Set the maximum number of active Sessions allowed, or -1 for
* no limit.
*
* @param max The new maximum number of sessions
*/
@Override
public void setMaxActiveSessions(int max) {
this.maxActiveSessions = max;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java | package me.chanjar.weixin.common.session;
/**
* @author Daniel Qian
*/
public interface InternalSessionManager {
/**
* Return the active Session, associated with this Manager, with the
* specified session id (if any); otherwise return <code>null</code>.
*
* @param id The session id for the session to be returned
* @throws IllegalStateException if a new session cannot be
* instantiated for any reason
* @throws java.io.IOException if an input/output error occurs while
* processing this request
*/
InternalSession findSession(String id);
/**
* Construct and return a new session object, based on the default
* settings specified by this Manager's properties. The session
* id specified will be used as the session id.
* If a new session cannot be created for any reason, return
* <code>null</code>.
*
* @param sessionId The session id which should be used to create the
* new session; if <code>null</code>, a new session id will be
* generated
* @throws IllegalStateException if a new session cannot be
* instantiated for any reason
*/
InternalSession createSession(String sessionId);
/**
* Remove this Session from the active Sessions for this Manager.
*
* @param session Session to be removed
*/
void remove(InternalSession session);
/**
* Remove this Session from the active Sessions for this Manager.
*
* @param session Session to be removed
* @param update Should the expiration statistics be updated
*/
void remove(InternalSession session, boolean update);
/**
* Add this Session to the set of active Sessions for this Manager.
*
* @param session Session to be added
*/
void add(InternalSession session);
/**
* Returns the number of active sessions
*
* @return number of sessions active
*/
int getActiveSessions();
/**
* Get a session from the recycled ones or create a new empty one.
* The PersistentManager manager does not need to create session data
* because it reads it from the Store.
*/
InternalSession createEmptySession();
InternalSession[] findSessions();
/**
* Implements the Manager interface, direct call to processExpires
*/
void backgroundProcess();
/**
* Set the default maximum inactive interval (in seconds)
* for Sessions created by this Manager.
*
* @param interval The new default value
*/
void setMaxInactiveInterval(int interval);
/**
* <pre>
* Set the manager checks frequency.
* 设置每尝试多少次清理过期session,才真的会执行一次清理动作
* 要和{@link #setBackgroundProcessorDelay(int)}联合起来看
* 如果把这个数字设置为6(默认),那么就是说manager要等待 6 * backgroundProcessorDay的时间才会清理过期session
* </pre>
*
* @param processExpiresFrequency the new manager checks frequency
*/
void setProcessExpiresFrequency(int processExpiresFrequency);
/**
* <pre>
* Set the manager background processor delay
* 设置manager sleep几秒,尝试执行一次background操作(清理过期session)
* </pre>
*
* @param backgroundProcessorDelay
*/
void setBackgroundProcessorDelay(int backgroundProcessorDelay);
/**
* Set the maximum number of active Sessions allowed, or -1 for
* no limit.
* 设置最大活跃session数,默认无限
*
* @param max The new maximum number of sessions
*/
void setMaxActiveSessions(int max);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSessionManager.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSessionManager.java | package me.chanjar.weixin.common.session;
/**
* @author Daniel Qian
*/
public interface WxSessionManager {
/**
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
*/
WxSession getSession(String sessionId);
/**
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
*/
WxSession getSession(String sessionId, boolean create);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/Constants.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/Constants.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.chanjar.weixin.common.session;
/**
* Manifest constants for the <code>org.apache.catalina.session</code>
* package.
*
* @author Craig R. McClanahan
*/
public class Constants {
public static final String PACKAGE = "me.chanjar.weixin.common.session";
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSession.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSession.java | package me.chanjar.weixin.common.session;
/**
*
* @author Daniel Qian
*/
public interface InternalSession {
/**
* Return the <code>HttpSession</code> for which this object
* is the facade.
*/
WxSession getSession();
/**
* Return the <code>isValid</code> flag for this session.
*/
boolean isValid();
/**
* Set the <code>isValid</code> flag for this session.
*
* @param isValid The new value for the <code>isValid</code> flag
*/
void setValid(boolean isValid);
/**
* Return the session identifier for this session.
*/
String getIdInternal();
/**
* Perform the internal processing required to invalidate this session,
* without triggering an exception if the session has already expired.
*/
void expire();
/**
* Update the accessed time information for this session. This method
* should be called by the context when a request comes in for a particular
* session, even if the application does not reference it.
*/
void access();
/**
* End the access.
*/
void endAccess();
/**
* Set the creation time for this session. This method is called by the
* Manager when an existing Session instance is reused.
*
* @param time The new creation time
*/
void setCreationTime(long time);
/**
* Set the default maximum inactive interval (in seconds)
* for Sessions created by this Manager.
*
* @param interval The new default value
*/
void setMaxInactiveInterval(int interval);
/**
* Set the session identifier for this session.
*
* @param id The new session identifier
*/
void setId(String id);
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java | package me.chanjar.weixin.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <pre>
* 标识某个字段是否是必填的
* Created by Binary Wang on 2016/9/25.
* </pre>
*
* @author binarywang (https://github.com/binarywang)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Required {
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutor.java | package me.chanjar.weixin.common.executor;
import jodd.http.HttpConnectionProvider;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import java.io.IOException;
/**
* 通用文件上传执行器
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public abstract class CommonUploadRequestExecutor<H, P> implements RequestExecutor<String, CommonUploadParam> {
protected RequestHttp<H, P> requestHttp;
public CommonUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
this.requestHttp = requestHttp;
}
@Override
public void execute(String uri, CommonUploadParam data, ResponseHandler<String> handler, WxType wxType) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
/**
* 构造通用文件上传执行器
*
* @param requestHttp 请求信息
* @return 执行器
*/
@SuppressWarnings("unchecked")
public static RequestExecutor<String, CommonUploadParam> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new CommonUploadRequestExecutorApacheImpl(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new CommonUploadRequestExecutorJoddHttpImpl((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new CommonUploadRequestExecutorOkHttpImpl((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new CommonUploadRequestExecutorHttpComponentsImpl(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new IllegalArgumentException("不支持的http执行器类型:" + requestHttp.getRequestType());
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorOkHttpImpl.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorOkHttpImpl.java | package me.chanjar.weixin.common.executor;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.*;
import okio.BufferedSink;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
/**
* OkHttp 通用文件上传器
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public class CommonUploadRequestExecutorOkHttpImpl extends CommonUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public CommonUploadRequestExecutorOkHttpImpl(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, CommonUploadParam param, WxType wxType) throws WxErrorException, IOException {
RequestBody requestBody = new CommonUpdateDataToRequestBodyAdapter(param.getData());
RequestBody body = new MultipartBody.Builder()
.setType(MediaType.get("multipart/form-data"))
.addFormDataPart(param.getName(), param.getData().getFileName(), requestBody)
.build();
Request request = new Request.Builder().url(uri).post(body).build();
try (Response response = requestHttp.getRequestHttpClient().newCall(request).execute()) {
ResponseBody responseBody = response.body();
String responseContent = responseBody == null ? "" : responseBody.string();
if (responseContent.isEmpty()) {
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
}
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
}
/**
* 通用上传输入 到 OkHttp 请求提 适配器
*/
@AllArgsConstructor
public static class CommonUpdateDataToRequestBodyAdapter extends RequestBody {
private static final MediaType CONTENT_TYPE = MediaType.get("application/octet-stream");
private CommonUploadData data;
@Override
public long contentLength() {
return data.getLength();
}
@Nullable
@Override
public MediaType contentType() {
return CONTENT_TYPE;
}
@Override
public void writeTo(@NotNull BufferedSink bufferedSink) throws IOException {
InputStream inputStream = data.getInputStream();
int count;
byte[] buffer = new byte[4096];
while ((count = inputStream.read(buffer)) != -1) {
bufferedSink.write(buffer, 0, count);
}
inputStream.close();
}
@Override
public boolean isOneShot() {
return true;
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorJoddHttpImpl.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorJoddHttpImpl.java | package me.chanjar.weixin.common.executor;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import jodd.http.upload.Uploadable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.SneakyThrows;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
* JoddHttp 通用文件上传器
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public class CommonUploadRequestExecutorJoddHttpImpl extends CommonUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public CommonUploadRequestExecutorJoddHttpImpl(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, CommonUploadParam param, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.form(param.getName(), new CommonUploadParamToUploadableAdapter(param.getData()));
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
if (responseContent.isEmpty()) {
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
}
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
/**
* 通用上传参数 到 Uploadable 的适配器
*/
@Getter
@AllArgsConstructor
public static class CommonUploadParamToUploadableAdapter implements Uploadable<CommonUploadData> {
private CommonUploadData content;
@SneakyThrows
@Override
public byte[] getBytes() {
return content.readAllBytes();
}
@Override
public String getFileName() {
return content.getFileName();
}
@Override
public String getMimeType() {
return null;
}
@SneakyThrows
@Override
public int getSize() {
return (int) content.getLength();
}
@Override
public InputStream openInputStream() {
return content.getInputStream();
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorApacheImpl.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorApacheImpl.java | package me.chanjar.weixin.common.executor;
import lombok.Getter;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
import java.io.InputStream;
/**
* Apache HttpClient 通用文件上传器
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public class CommonUploadRequestExecutorApacheImpl extends CommonUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public CommonUploadRequestExecutorApacheImpl(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, CommonUploadParam param, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (param != null) {
CommonUploadData data = param.getData();
InnerStreamBody part = new InnerStreamBody(data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFileName(), data.getLength());
HttpEntity entity = MultipartEntityBuilder
.create()
.addPart(param.getName(), part)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
if (StringUtils.isEmpty(responseContent)) {
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
}
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
/**
* 内部流 请求体
*/
@Getter
public static class InnerStreamBody extends InputStreamBody {
private final long contentLength;
public InnerStreamBody(final InputStream in, final ContentType contentType, final String filename, long contentLength) {
super(in, contentType, filename);
this.contentLength = contentLength;
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorHttpComponentsImpl.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorHttpComponentsImpl.java | package me.chanjar.weixin.common.executor;
import lombok.Getter;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.InputStreamBody;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.IOException;
import java.io.InputStream;
/**
* Apache HttpComponents 通用文件上传器
*/
public class CommonUploadRequestExecutorHttpComponentsImpl extends CommonUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public CommonUploadRequestExecutorHttpComponentsImpl(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, CommonUploadParam param, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (param != null) {
CommonUploadData data = param.getData();
InnerStreamBody part = new InnerStreamBody(data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFileName(), data.getLength());
HttpEntity entity = MultipartEntityBuilder
.create()
.addPart(param.getName(), part)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
if (StringUtils.isEmpty(responseContent)) {
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
}
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
/**
* 内部流 请求体
*/
@Getter
public static class InnerStreamBody extends InputStreamBody {
private final long contentLength;
public InnerStreamBody(final InputStream in, final ContentType contentType, final String filename, long contentLength) {
super(in, contentType, filename);
this.contentLength = contentLength;
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernHttpComponentsRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernHttpComponentsRequestExecutor.java | package me.chanjar.weixin.common.requestexecuter.ocr;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
public class OcrDiscernHttpComponentsRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> {
public OcrDiscernHttpComponentsRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("file", file)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java | package me.chanjar.weixin.common.requestexecuter.ocr;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
/**
* .
*
* @author zhayueran
* created on 2019/6/27 15:06
*/
public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor<String, File> {
protected RequestHttp<H, P> requestHttp;
public OcrDiscernRequestExecutor(RequestHttp<H, P> requestHttp) {
this.requestHttp = requestHttp;
}
@Override
public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
@SuppressWarnings("unchecked")
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new OcrDiscernApacheHttpRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case HTTP_COMPONENTS:
return new OcrDiscernHttpComponentsRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new IllegalArgumentException("不支持的http执行器类型:" + requestHttp.getRequestType());
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernApacheHttpRequestExecutor.java | package me.chanjar.weixin.common.requestexecuter.ocr;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
/**
* .
*
* @author : zhayueran
* created on 2019/6/27 14:06
*/
public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> {
public OcrDiscernApacheHttpRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("file", file)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/CommonUploadData.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/CommonUploadData.java | package me.chanjar.weixin.common.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
import java.io.*;
import java.nio.file.Files;
/**
* 通用文件上传数据
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Slf4j
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonUploadData implements Serializable {
/**
* 文件名,如:1.jpg
*/
@Nullable
private String fileName;
/**
* 文件内容
*
* @see FileInputStream 文件输入流
* @see ByteArrayInputStream 字节输入流
*/
@NotNull
private InputStream inputStream;
/**
* 文件内容长度(字节数)
*/
private long length;
/**
* 从文件构造
*
* @param file 文件
* @return 通用文件上传数据
*/
@SneakyThrows
public static CommonUploadData fromFile(File file) {
return new CommonUploadData(file.getName(), Files.newInputStream(file.toPath()), file.length());
}
/**
* 读取所有字节,此方法会关闭输入流
*
* @return 字节数组
*/
@SneakyThrows
public byte[] readAllBytes() {
byte[] bytes = new byte[(int) length];
//noinspection ResultOfMethodCallIgnored
inputStream.read(bytes);
inputStream.close();
return bytes;
}
@Override
public String toString() {
return String.format("{fileName:%s, length:%s}", fileName, length);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessTokenEntity.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessTokenEntity.java | package me.chanjar.weixin.common.bean;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* token
*
* @author cn
*/
@Getter
@Setter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxAccessTokenEntity extends WxAccessToken {
private String appid;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java | package me.chanjar.weixin.common.bean;
import java.io.Serializable;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
/**
* 卡券Api签名.
*
* @author YuJian
* @version 15/11/8
*/
@Data
public class WxCardApiSignature implements Serializable {
private static final long serialVersionUID = 158176707226975979L;
private String appId;
private String cardId;
private String cardType;
private String locationId;
private String code;
private String openId;
private Long timestamp;
private String nonceStr;
private String signature;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java | package me.chanjar.weixin.common.bean;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* jspai signature.
*
* @author Daniel Qian
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxJsapiSignature implements Serializable {
private static final long serialVersionUID = -1116808193154384804L;
private String appId;
private String nonceStr;
private long timestamp;
private String url;
private String signature;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxOAuth2UserInfo.java | package me.chanjar.weixin.common.bean;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* oauth2用户个人信息.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-10-11
*/
@Data
public class WxOAuth2UserInfo implements Serializable {
private static final long serialVersionUID = 3181943506448954725L;
/**
* openid 普通用户的标识,对当前开发者帐号唯一
*/
private String openid;
/**
* nickname 普通用户昵称
*/
private String nickname;
/**
* sex 普通用户性别,1为男性,2为女性
*/
private Integer sex;
/**
* city 普通用户个人资料填写的城市
*/
private String city;
/**
* province 普通用户个人资料填写的省份
*/
private String province;
/**
* country 国家,如中国为CN
*/
private String country;
/**
* headimgurl 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),
* 用户没有头像时该项为空
*/
@SerializedName("headimgurl")
private String headImgUrl;
/**
* unionid 用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。
*/
@SerializedName("unionid")
private String unionId;
/**
* privilege 用户特权信息,json数组,如微信沃卡用户为(chinaunicom)
*/
@SerializedName("privilege")
private String[] privileges;
public static WxOAuth2UserInfo fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOAuth2UserInfo.class);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ToJson.java | package me.chanjar.weixin.common.bean;
/**
* 包含toJson()方法的接口.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-10-05
*/
public interface ToJson {
/**
* 转换为json字符串
* @return json字符串
*/
String toJson();
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/CommonUploadParam.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/CommonUploadParam.java | package me.chanjar.weixin.common.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.Serializable;
/**
* 通用文件上传参数
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonUploadParam implements Serializable {
/**
* 文件对应的接口参数名称(非文件名),如:media
*/
@NotNull
private String name;
/**
* 上传数据
*/
@NotNull
private CommonUploadData data;
/**
* 从文件构造
*
* @param name 参数名,如:media
* @param file 文件
* @return 文件上传参数对象
*/
@SneakyThrows
public static CommonUploadParam fromFile(String name, File file) {
return new CommonUploadParam(name, CommonUploadData.fromFile(file));
}
/**
* 从字节数组构造
*
* @param name 参数名,如:media
* @param bytes 字节数组
* @return 文件上传参数对象
*/
@SneakyThrows
public static CommonUploadParam fromBytes(String name, @Nullable String fileName, byte[] bytes) {
return new CommonUploadParam(name, new CommonUploadData(fileName, new ByteArrayInputStream(bytes), bytes.length));
}
@Override
public String toString() {
return String.format("{name:%s, data:%s}", name, data);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java | package me.chanjar.weixin.common.bean;
import java.io.Serializable;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
/**
* access token.
*
* @author Daniel Qian
*/
@Data
public class WxAccessToken implements Serializable {
private static final long serialVersionUID = 8709719312922168909L;
private String accessToken;
private int expiresIn = -1;
public static WxAccessToken fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxAccessToken.class);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxNetCheckResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxNetCheckResult.java | package me.chanjar.weixin.common.bean;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 网络检测.
* @author billytomato
*/
@Data
public class WxNetCheckResult implements Serializable {
private static final long serialVersionUID = 6918924418847404172L;
private List<WxNetCheckDnsInfo> dnsInfos = new ArrayList<>();
private List<WxNetCheckPingInfo> pingInfos = new ArrayList<>();
public static WxNetCheckResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxNetCheckResult.class);
}
@Data
public static class WxNetCheckDnsInfo implements Serializable{
private static final long serialVersionUID = 82631178029516008L;
private String ip;
private String realOperator;
}
@Data
public static class WxNetCheckPingInfo implements Serializable{
private static final long serialVersionUID = -1871970825359178319L;
private String ip;
private String fromOperator;
private String packageLoss;
private String time;
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/oauth2/WxOAuth2AccessToken.java | package me.chanjar.weixin.common.bean.oauth2;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842
*
* @author Daniel Qian
*/
@Data
public class WxOAuth2AccessToken implements Serializable {
private static final long serialVersionUID = -1345910558078620805L;
@SerializedName("access_token")
private String accessToken;
@SerializedName("expires_in")
private int expiresIn = -1;
@SerializedName("refresh_token")
private String refreshToken;
@SerializedName("openid")
private String openId;
@SerializedName("scope")
private String scope;
/**
* 是否为快照页模式虚拟账号,只有当用户是快照页模式虚拟账号时返回,值为1
*/
@SerializedName("is_snapshotuser")
private Integer snapshotUser;
/**
* https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11513156443eZYea&version=&lang=zh_CN.
* 本接口在scope参数为snsapi_base时不再提供unionID字段。
*/
@SerializedName("unionid")
private String unionId;
public static WxOAuth2AccessToken fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOAuth2AccessToken.class);
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrBizLicenseResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrBizLicenseResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* @author Theo Nie
*/
@Data
public class WxOcrBizLicenseResult implements Serializable {
private static final long serialVersionUID = -5007671093920178291L;
/**
* 注册号
*/
@SerializedName("reg_num")
private String regNum;
/**
* 编号
*/
@SerializedName("serial")
private String serial;
/**
* 法定代表人姓名
*/
@SerializedName("legal_representative")
private String legalRepresentative;
/**
* 企业名称
*/
@SerializedName("enterprise_name")
private String enterpriseName;
/**
* 组成形式
*/
@SerializedName("type_of_organization")
private String typeOfOrganization;
/**
* 经营场所/企业住所
*/
@SerializedName("address")
private String address;
/**
* 公司类型
*/
@SerializedName("type_of_enterprise")
private String typeOfEnterprise;
/**
* 经营范围
*/
@SerializedName("business_scope")
private String businessScope;
/**
* 注册资本
*/
@SerializedName("registered_capital")
private String registeredCapital;
/**
* 实收资本
*/
@SerializedName("paid_in_capital")
private String paidInCapital;
/**
* 营业期限
*/
@SerializedName("valid_period")
private String validPeriod;
/**
* 注册日期/成立日期
*/
@SerializedName("registered_date")
private String registeredDate;
/**
* 营业执照位置
*/
@SerializedName("cert_position")
private CertPosition certPosition;
/**
* 图片大小
*/
@SerializedName("img_size")
private WxOcrImgSize imgSize;
public static WxOcrBizLicenseResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrBizLicenseResult.class);
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
@Data
public static class CertPosition implements Serializable {
private static final long serialVersionUID = 290286813344131863L;
@SerializedName("pos")
private WxOcrPos pos;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrCommResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrCommResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* @author Theo Nie
*/
@Data
public class WxOcrCommResult implements Serializable {
private static final long serialVersionUID = 455833771627756440L;
@SerializedName("img_size")
private WxOcrImgSize imgSize;
@SerializedName("items")
private List<Items> items;
public static WxOcrCommResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrCommResult.class);
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
@Data
public static class Items implements Serializable {
private static final long serialVersionUID = 3066181677009102791L;
@SerializedName("text")
private String text;
@SerializedName("pos")
private WxOcrPos pos;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrDrivingResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrDrivingResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* @author Theo Nie
*/
@Data
public class WxOcrDrivingResult implements Serializable {
private static final long serialVersionUID = -7477484374200211303L;
/**
* 车牌号码
*/
@SerializedName("plate_num")
private String plateNum;
/**
* 车辆类型
*/
@SerializedName("vehicle_type")
private String vehicleType;
/**
* 所有人
*/
@SerializedName("owner")
private String owner;
/**
* 住址
*/
@SerializedName("addr")
private String addr;
/**
* 使用性质
*/
@SerializedName("use_character")
private String useCharacter;
/**
* 品牌型号
*/
@SerializedName("model")
private String model;
/**
* 车辆识别代码
*/
@SerializedName("vin")
private String vin;
/**
* 发动机号码
*/
@SerializedName("engine_num")
private String engineNum;
/**
* 注册日期
*/
@SerializedName("register_date")
private String registerDate;
/**
* 发证日期
*/
@SerializedName("issue_date")
private String issueDate;
/**
* 车牌号码
*/
@SerializedName("plate_num_b")
private String plateNumB;
/**
* 号牌
*/
@SerializedName("record")
private String record;
/**
* 核定载人数
*/
@SerializedName("passengers_num")
private String passengersNum;
/**
* 总质量
*/
@SerializedName("total_quality")
private String totalQuality;
/**
* 整备质量
*/
@SerializedName("prepare_quality")
private String prepareQuality;
/**
* 外廓尺寸
*/
@SerializedName("overall_size")
private String overallSize;
/**
* 卡片正面位置(检测到卡片正面才会返回)
*/
@SerializedName("card_position_front")
private CardPosition cardPositionFront;
/**
* 卡片反面位置(检测到卡片反面才会返回)
*/
@SerializedName("card_position_back")
private CardPosition cardPositionBack;
/**
* 图片大小
*/
@SerializedName("img_size")
private WxOcrImgSize imgSize;
@Data
public static class CardPosition implements Serializable {
private static final long serialVersionUID = 2884515165228160517L;
@SerializedName("pos")
private WxOcrPos pos;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
public static WxOcrDrivingResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrDrivingResult.class);
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrDrivingLicenseResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrDrivingLicenseResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* @author Theo Nie
*/
@Data
public class WxOcrDrivingLicenseResult implements Serializable {
private static final long serialVersionUID = -6984670645802585738L;
/**
* 证号
*/
@SerializedName("id_num")
private String idNum;
/**
* 姓名
*/
@SerializedName("name")
private String name;
/**
* 性别
*/
@SerializedName("sex")
private String sex;
/**
* 国籍
*/
@SerializedName("nationality")
private String nationality;
/**
* 住址
*/
@SerializedName("address")
private String address;
/**
* 出生日期
*/
@SerializedName("birth_date")
private String birthDate;
/**
* 初次领证日期
*/
@SerializedName("issue_date")
private String issueDate;
/**
* 准驾车型
*/
@SerializedName("car_class")
private String carClass;
/**
* 有效期限起始日
*/
@SerializedName("valid_from")
private String validFrom;
/**
* 有效期限终止日
*/
@SerializedName("valid_to")
private String validTo;
/**
* 印章文字
*/
@SerializedName("official_seal")
private String officialSeal;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
public static WxOcrDrivingLicenseResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrDrivingLicenseResult.class);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrBankCardResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrBankCardResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* 银行卡OCR识别结果
*
* @author Theo Nie
*/
@Data
public class WxOcrBankCardResult implements Serializable {
private static final long serialVersionUID = 554136620394204143L;
@SerializedName("number")
private String number;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
public static WxOcrBankCardResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrBankCardResult.class);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrIdCardResult.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* OCR身份证识别结果.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2019-06-23
*/
@Data
public class WxOcrIdCardResult implements Serializable {
private static final long serialVersionUID = 8184352486986729980L;
@SerializedName("type")
private String type;
@SerializedName("name")
private String name;
@SerializedName("id")
private String id;
@SerializedName("addr")
private String addr;
@SerializedName("gender")
private String gender;
@SerializedName("nationality")
private String nationality;
@SerializedName("valid_date")
private String validDate;
public static WxOcrIdCardResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOcrIdCardResult.class);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrPos.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrPos.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* @author Theo Nie
*/
@Data
public class WxOcrPos implements Serializable {
private static final long serialVersionUID = 4204160206873907920L;
@SerializedName("left_top")
private Coordinate leftTop;
@SerializedName("right_top")
private Coordinate rightTop;
@SerializedName("right_bottom")
private Coordinate rightBottom;
@SerializedName("left_bottom")
private Coordinate leftBottom;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
@Data
public static class Coordinate implements Serializable {
private static final long serialVersionUID = 8675059935386304399L;
@SerializedName("x")
private int x;
@SerializedName("y")
private int y;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrImgSize.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/ocr/WxOcrImgSize.java | package me.chanjar.weixin.common.bean.ocr;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
* @author Theo Nie
*/
@Data
public class WxOcrImgSize implements Serializable {
private static final long serialVersionUID = 5234409123551074168L;
@SerializedName("w")
private int w;
@SerializedName("h")
private int h;
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopPicFileResult.java | package me.chanjar.weixin.common.bean.result;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopPicFileResult implements Serializable {
private String mediaId;
private String payMediaId;
private String tempImgUrl;
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
binarywang/WxJava | https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java | weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMinishopImageUploadCustomizeResult.java | package me.chanjar.weixin.common.bean.result;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.Data;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
@Data
public class WxMinishopImageUploadCustomizeResult implements Serializable {
private String errcode;
private String errmsg;
private WxMinishopPicFileCustomizeResult imgInfo;
public static WxMinishopImageUploadCustomizeResult fromJson(String json) {
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
WxMinishopImageUploadCustomizeResult result = new WxMinishopImageUploadCustomizeResult();
result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
if (result.getErrcode().equals("0")) {
WxMinishopPicFileCustomizeResult picFileResult = new WxMinishopPicFileCustomizeResult();
JsonObject picObject = jsonObject.get("img_info").getAsJsonObject();
if (picObject.has("media_id")) {
picFileResult.setMediaId(picObject.get("media_id").getAsString());
}
if (picObject.has("temp_img_url")) {
picFileResult.setTempImgUrl(picObject.get("temp_img_url").getAsString());
}
result.setImgInfo(picFileResult);
}
return result;
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}
| java | Apache-2.0 | 84b5c4d2d0774f800237634e5d0336f53c004fe3 | 2026-01-04T14:46:39.499027Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.