|
|
@@ -12,6 +12,8 @@ import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.util.Assert;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.util.Map;
|
|
|
@@ -49,11 +51,13 @@ public class AbstractAgent {
|
|
|
return url + "&_signature=" + HmacUtils.encode(url);
|
|
|
}
|
|
|
|
|
|
- protected boolean postForEntity(String url, Map<String, Object> vars) {
|
|
|
+ public boolean postForEntity(String url, Map<String, Object> vars) {
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
headers.add("referer", getSignature());
|
|
|
- HttpEntity<Map<String, Object>> request = new HttpEntity<>(vars, headers);
|
|
|
+ MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
|
|
|
+ formData.setAll(vars);
|
|
|
+ HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(formData, headers);
|
|
|
String returnStr = restTemplate.postForEntity(getUASUrl() + url, request, String.class).getBody();
|
|
|
ResultWrap<String> wrap = JSON.parseObject(returnStr, new TypeReference<ResultWrap<String>>(){});
|
|
|
return wrap.isSuccess();
|