Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
vk.api/messages.send
link.com/param1¶m2
link.com/?param1¶m2
private String request(String httpMethod, String targetURL) { String tURL = "https://api.vk.com/method/" + targetURL; HttpURLConnection connection = null; String urlResponse = ""; URL url = new URL(tURL); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod(httpMethod); connection.setUseCaches(false); connection.setDoOutput(true); DataOutputStream wr = new DataOutputStream ( connection.getOutputStream()); wr.writeBytes(urlResponse); wr.close(); InputStream is = connection.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); StringBuilder response = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { response.append(line); response.append('\r'); } rd.close(); return response.toString(); } request("POST", String.format("messages.send?peer_id=%s&v=%s&access_token=%s&message=%s", app.vkID, app.vkApiV, app.vkToken, " link.com/param1¶m2"));