public static void main(String[] args) throws Exception {
HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http");
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
builder.build());
HttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.setDefaultRequestConfig(RequestConfig.custom()
.setProxy(proxy)
.setCookieSpec(CookieSpecs.STANDARD).build())
.build();
HttpPost httpPost = new HttpPost("https://api.vk.com/method/messages.send");
HttpEntity entity = MultipartEntityBuilder
.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addTextBody("user_id", "")
.addTextBody("message", "Что бы тут я не написал в сообщении будут вопросы")
.addTextBody("access_token", "")
.addTextBody("v", "5")
.build();
httpPost.setEntity(entity);
System.out.println (httpPost.getURI());
HttpResponse response1 = httpClient.execute(httpPost);
String responseString = new BasicResponseHandler().handleResponse(response1);
System.out.println(responseString);
System.out.println(response1.getStatusLine());
}