update something..

This commit is contained in:
jinyu 2015-05-30 21:00:05 +08:00
parent 48442d1c43
commit a1cd537db6
3 changed files with 10 additions and 6 deletions

View File

@ -127,11 +127,13 @@ public class SimpleHttpClient implements HttpClient {
if (request instanceof HttpEntityRequest) { if (request instanceof HttpEntityRequest) {
httpEntity = ((HttpEntityRequest) request).getEntity(); httpEntity = ((HttpEntityRequest) request).getEntity();
connection.setUseCaches(false); connection.setUseCaches(false);
if (httpEntity != null) {
connection.setFixedLengthStreamingMode(httpEntity connection.setFixedLengthStreamingMode(httpEntity
.getContentLength()); .getContentLength());
connection.setRequestProperty("Content-Type", httpEntity connection.setRequestProperty("Content-Type", httpEntity
.getContentType().getMimeType()); .getContentType().getMimeType());
} }
}
connection.connect(); connection.connect();
// open stream // open stream
if (httpEntity != null) { if (httpEntity != null) {

View File

@ -23,6 +23,7 @@ import com.foxinmy.weixin4j.http.entity.ByteArrayEntity;
import com.foxinmy.weixin4j.http.entity.FileEntity; import com.foxinmy.weixin4j.http.entity.FileEntity;
import com.foxinmy.weixin4j.http.entity.FormUrlEntity; import com.foxinmy.weixin4j.http.entity.FormUrlEntity;
import com.foxinmy.weixin4j.http.entity.StringEntity; import com.foxinmy.weixin4j.http.entity.StringEntity;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.util.ErrorUtil; import com.foxinmy.weixin4j.util.ErrorUtil;
import com.foxinmy.weixin4j.util.MapUtil; import com.foxinmy.weixin4j.util.MapUtil;
import com.foxinmy.weixin4j.util.StringUtil; import com.foxinmy.weixin4j.util.StringUtil;
@ -194,6 +195,7 @@ public class WeixinHttpClient extends SimpleHttpClient {
.replaceFirst("</retmsg>", "</return_msg>") .replaceFirst("</retmsg>", "</return_msg>")
.replaceFirst("</root>", "</xml>"); .replaceFirst("</root>", "</xml>");
xmlResult = XmlStream.get(newXml, XmlResult.class); xmlResult = XmlStream.get(newXml, XmlResult.class);
response.setContent(newXml.getBytes(Consts.UTF_8));
} }
response.setXmlResult(true); response.setXmlResult(true);
if (xmlResult.getReturnCode().equals("0")) { if (xmlResult.getReturnCode().equals("0")) {

View File

@ -101,12 +101,12 @@ public class CustomApi extends MpApi {
String text = ""; String text = "";
if (isOnline) { if (isOnline) {
String getonlinekflist_uri = getRequestUri("getonlinekflist_uri"); String getonlinekflist_uri = getRequestUri("getonlinekflist_uri");
WeixinResponse response = weixinClient.post(String.format(getonlinekflist_uri, WeixinResponse response = weixinClient.get(String.format(getonlinekflist_uri,
token.getAccessToken())); token.getAccessToken()));
text = response.getAsJson().getString("kf_online_list"); text = response.getAsJson().getString("kf_online_list");
} else { } else {
String getkflist_uri = getRequestUri("getkflist_uri"); String getkflist_uri = getRequestUri("getkflist_uri");
WeixinResponse response = weixinClient.post(String.format(getkflist_uri, WeixinResponse response = weixinClient.get(String.format(getkflist_uri,
token.getAccessToken())); token.getAccessToken()));
text = response.getAsJson().getString("kf_list"); text = response.getAsJson().getString("kf_list");
} }