- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中me.chanjar.weixin.common.exception.WxErrorException
类的一些代码示例,展示了WxErrorException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WxErrorException
类的具体详情如下:
包路径:me.chanjar.weixin.common.exception.WxErrorException
类名称:WxErrorException
暂无
代码示例来源:origin: chanjarster/weixin-java-tools
return executeInternal(executor, uri, data);
} catch (WxErrorException e) {
WxError error = e.getError();
代码示例来源:origin: chanjarster/weixin-java-tools
public String templateSend(WxMpTemplateMessage templateMessage) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send";
String responseContent = execute(new SimplePostRequestExecutor(), url, templateMessage.toJson());
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
final JsonObject jsonObject = tmpJsonElement.getAsJsonObject();
if (jsonObject.get("errcode").getAsInt() == 0)
return jsonObject.get("msgid").getAsString();
throw new WxErrorException(WxError.fromJson(responseContent));
}
代码示例来源:origin: chanjarster/weixin-java-tools
return executor.execute(getHttpclient(), httpProxy, uriWithAccessToken, data);
} catch (WxErrorException e) {
WxError error = e.getError();
throw new WxErrorException(error);
代码示例来源:origin: aillamsun/genesis
/**
* @param @param longUrl
* @param @return
* @param @throws WxErrorException 参数
* @return String 返回类型
* @throws
* @Title: getShortUrl
* @Description: TODO 获取短链接
*/
public static String getShortUrl(String longUrl) {
try {
return WxMpServiceFactory.getWxMpService().shortUrl(longUrl);
} catch (WxErrorException e) {
e.printStackTrace();
return "";
}
}
代码示例来源:origin: yjjdick/sdb-mall
this.logger.error(e.getMessage(), e);
return R.error(e.toString());
代码示例来源:origin: chanjarster/weixin-java-tools
return executor.execute(getHttpclient(), httpProxy, uriWithAccessToken, data);
} catch (WxErrorException e) {
WxError error = e.getError();
throw new WxErrorException(error);
代码示例来源:origin: yjjdick/sdb-mall
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService,
WxSessionManager sessionManager) {
if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
//TODO 可以选择将消息保存到本地
}
//当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
try {
if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
&& weixinService.getKefuService().kfOnlineList()
.getKfOnlineList().size() > 0) {
return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
.fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser()).build();
}
} catch (WxErrorException e) {
e.printStackTrace();
}
//TODO 组装回复消息
String content = "收到信息内容:" + JsonUtils.toJson(wxMessage);
return new TextBuilder().build(content, wxMessage, weixinService);
}
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material";
Map<String, Object> params = new HashMap<>();
params.put("type", type);
params.put("offset", offset);
params.put("count", count);
String responseText = post(url, WxGsonBuilder.create().toJson(params));
WxError wxError = WxError.fromJson(responseText);
if (wxError.getErrorCode() == 0) {
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);
} else {
throw new WxErrorException(wxError);
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
return executeInternal(executor, uri, data);
} catch (WxErrorException e) {
WxError error = e.getError();
代码示例来源:origin: me.chanjar/weixin-java-mp
return executor.execute(getHttpclient(), httpProxy, uriWithAccessToken, data);
} catch (WxErrorException e) {
WxError error = e.getError();
throw new WxErrorException(error);
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material";
Map<String, Object> params = new HashMap<>();
params.put("type", WxConsts.MATERIAL_NEWS);
params.put("offset", offset);
params.put("count", count);
String responseText = post(url, WxGsonBuilder.create().toJson(params));
WxError wxError = WxError.fromJson(responseText);
if (wxError.getErrorCode() == 0) {
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
} else {
throw new WxErrorException(wxError);
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMenu menuTryMatch(String userid) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch";
try {
String resultContent = execute(new SimpleGetRequestExecutor(), url, "user_id=" + userid);
return WxMenu.fromJson(resultContent);
} catch (WxErrorException e) {
// 46003 不存在的菜单数据 46002 不存在的菜单版本
if (e.getError().getErrorCode() == 46003 || e.getError().getErrorCode() == 46002) {
return null;
}
throw e;
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
public Boolean execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
httpPost.setConfig(config);
}
Map<String, String> params = new HashMap<>();
params.put("media_id", materialId);
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
CloseableHttpResponse response = httpclient.execute(httpPost);
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
} else {
return true;
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
@Override
public WxMenu menuGet(String agentId) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + agentId;
try {
String resultContent = get(url, null);
return WxMenu.fromJson(resultContent);
} catch (WxErrorException e) {
// 46003 不存在的菜单数据
if (e.getError().getErrorCode() == 46003) {
return null;
}
throw e;
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
public InputStream execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
httpPost.setConfig(config);
}
Map<String, String> params = new HashMap<>();
params.put("media_id", materialId);
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
CloseableHttpResponse response = httpclient.execute(httpPost);
// 下载媒体文件出错
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);
byte[] responseContent = IOUtils.toByteArray(inputStream);
String responseContentString = new String(responseContent, "UTF-8");
if (responseContentString.length() < 100) {
try {
WxError wxError = WxGsonBuilder.create().fromJson(responseContentString, WxError.class);
if (wxError.getErrorCode() != 0) {
throw new WxErrorException(wxError);
}
} catch (com.google.gson.JsonSyntaxException ex) {
return new ByteArrayInputStream(responseContent);
}
}
return new ByteArrayInputStream(responseContent);
}
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMenu menuGet() throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/menu/get";
try {
String resultContent = execute(new SimpleGetRequestExecutor(), url, null);
return WxMenu.fromJson(resultContent);
} catch (WxErrorException e) {
// 46003 不存在的菜单数据
if (e.getError().getErrorCode() == 46003) {
return null;
}
throw e;
}
}
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMpMaterialNews execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
httpPost.setConfig(config);
}
Map<String, String> params = new HashMap<>();
params.put("media_id", materialId);
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
CloseableHttpResponse response = httpclient.execute(httpPost);
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
} else {
return WxMpGsonBuilder.create().fromJson(responseContent, WxMpMaterialNews.class);
}
}
代码示例来源:origin: me.chanjar/weixin-java-mp
return executeInternal(executor, uri, data);
} catch (WxErrorException e) {
WxError error = e.getError();
代码示例来源:origin: chanjarster/weixin-java-tools
public WxMpMaterialVideoInfoResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
httpPost.setConfig(config);
}
Map<String, String> params = new HashMap<>();
params.put("media_id", materialId);
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
CloseableHttpResponse response = httpclient.execute(httpPost);
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
} else {
return WxMpMaterialVideoInfoResult.fromJson(responseContent);
}
}
代码示例来源:origin: me.chanjar/weixin-java-mp
public WxMenu menuTryMatch(String userid) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch";
try {
String resultContent = execute(new SimpleGetRequestExecutor(), url, "user_id=" + userid);
return WxMenu.fromJson(resultContent);
} catch (WxErrorException e) {
// 46003 不存在的菜单数据 46002 不存在的菜单版本
if (e.getError().getErrorCode() == 46003 || e.getError().getErrorCode() == 46002) {
return null;
}
throw e;
}
}
本文整理了Java中me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker类的一些代码示例,展示了WxMessageInMemor
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter类的一些代码示例,展示了WxMpMessageRouter类的具体用法。这些代码示例主要来源于G
本文整理了Java中me.chanjar.weixin.common.exception.WxErrorException类的一些代码示例,展示了WxErrorException类的具体用法。这些代码
本文实例讲述了php版微信支付api.mch.weixin.qq.com域名解析慢原因与解决方法。分享给大家供大家参考,具体如下: 微信支付api.mch.weixin.qq.com域名解析慢了,
本文整理了Java中me.chanjar.weixin.common.util.xml.XStreamInitializer类的一些代码示例,展示了XStreamInitializer类的具体用法。这
本文整理了Java中com.riversoft.weixin.common.util.XmlObjectMapper类的一些代码示例,展示了XmlObjectMapper类的具体用法。这些代码示例主要
本文整理了Java中me.chanjar.weixin.mp.api.impl.WxMpServiceImpl类的一些代码示例,展示了WxMpServiceImpl类的具体用法。这些代码示例主要来源于
本文整理了Java中me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker.checkBackgroundProcessStart
本文整理了Java中me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker.()方法的一些代码示例,展示了WxMessageInM
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter.getRules()方法的一些代码示例,展示了WxMpMessageRouter.getRul
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter.rule()方法的一些代码示例,展示了WxMpMessageRouter.rule()的具体用
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter.sessionEndAccess()方法的一些代码示例,展示了WxMpMessageRoute
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter.route()方法的一些代码示例,展示了WxMpMessageRouter.route()的具
本文整理了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter.()方法的一些代码示例,展示了WxMpMessageRouter.()的具体用法。这些代码示例
本文整理了Java中me.chanjar.weixin.common.exception.WxErrorException.printStackTrace()方法的一些代码示例,展示了WxErrorE
本文整理了Java中me.chanjar.weixin.common.exception.WxErrorException.()方法的一些代码示例,展示了WxErrorException.()的具体用
本文整理了Java中me.chanjar.weixin.common.exception.WxErrorException.getError()方法的一些代码示例,展示了WxErrorExceptio
本文整理了Java中me.chanjar.weixin.common.util.xml.XStreamInitializer.getInstance()方法的一些代码示例,展示了XStreamInit
本文整理了Java中com.riversoft.weixin.common.util.XmlObjectMapper.fromXml()方法的一些代码示例,展示了XmlObjectMapper.fro
本文整理了Java中com.riversoft.weixin.common.util.XmlObjectMapper.toXml()方法的一些代码示例,展示了XmlObjectMapper.toXml
我是一名优秀的程序员,十分优秀!