fix: 修复微信服务号中文乱码问题
This commit is contained in:
parent
df19957523
commit
0b5f8be3b5
@ -4,18 +4,25 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cicdi.notify.*;
|
import com.cicdi.notify.*;
|
||||||
import com.cicdi.notify.wechat.WechatProvider;
|
import com.cicdi.notify.wechat.WechatProvider;
|
||||||
|
import org.apache.http.Consts;
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.HttpHeaders;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@ -87,8 +94,8 @@ public class WechatSubscriptionNotifier implements Notifier<WechatSubscriptionTe
|
|||||||
.addParameter("access_token", getToken())
|
.addParameter("access_token", getToken())
|
||||||
.build();
|
.build();
|
||||||
HttpPost httpPost = new HttpPost(sendMessageURI);
|
HttpPost httpPost = new HttpPost(sendMessageURI);
|
||||||
httpPost.setHeader("Content-Type", "application/json;charset=utf8");
|
httpPost.setHeader("Content-Type", "application/json; charset=UTF-8");
|
||||||
StringEntity requestBody = new StringEntity(template.createJsonRequest());
|
StringEntity requestBody = new StringEntity(template.createJsonRequest(), ContentType.APPLICATION_JSON);
|
||||||
httpPost.setEntity(requestBody);
|
httpPost.setEntity(requestBody);
|
||||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||||
JSONObject responseJson = JSON.parseObject(EntityUtils.toString(response.getEntity()));
|
JSONObject responseJson = JSON.parseObject(EntityUtils.toString(response.getEntity()));
|
||||||
|
Loading…
Reference in New Issue
Block a user