package jp.co.kentaku.kikan.app.f.fy.fye200.dpfye20001;
import net.sf.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class Talk2 {
public static String testApiRequest(MultiValueMap<String, Object> requestParams2) {
RestTemplate restTemplate = new RestTemplate();
String url = “https://stg.dk.ielove.jp/crmapi/newdonna/auth/v1”;
Map<String,Object> map= new HashMap();
map.put("userid", "999999");
map.put("password", "password");
map.put("passphrase", "passphrase");
map.put("tracekeyword", "");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
JSONObject jsonObject = JSONObject.fromObject(map);
HttpEntity<String> request1 = new HttpEntity<String>(jsonObject.toString(), headers);
Properties systemProperties = System.getProperties();
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "192.168.11.5");
System.setProperty("http.proxyPort", "12080");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("http://proxy04.kentaku.co.jp", 12080));
// 针对https也开启代理
System.setProperty("https.proxyHost", "192.168.11.5");
System.setProperty("https.proxyPort", "12080");
String result2 = restTemplate.postForObject(url, request1, String.class);
return result2;
}
//测试是否有效
public static void main(String[] args) {
testApiRequest(null);
}
}