Answer the question
In order to leave comments, you need to log in
How to authorize vkontakte without api?
Wrote a code that performs VK authorization
BufferedReader request = (HttpURLConnection) (new URL("https://vk.com/audio")).openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
String line;
StringBuffer output = new StringBuffer();
for (Map.Entry<String, List<String>> k : request.getHeaderFields().entrySet()) {
if (k.toString().contains("Set-Cookie="))
cook = k.toString().replace("Set-Cookie=[", "").replace("]", "").replaceAll("expires=(.*?) GMT; path=/; ", "").replaceAll("domain=.vk.com, ", "");
}
while ((line = reader.readLine()) != null)
output.append(line);
URL parse = new URL(output.toString().split("action=\"")[1].split("\"")[0]+"&email=EMAIL&pass=PASS");
URL post = new URL(parse.getProtocol()+"://"+parse.getHost()+parse.getPath());
String query = parse.getQuery();
request = (HttpURLConnection) post.openConnection();
request.setRequestMethod("POST");
request.setDoOutput(true);
request.setInstanceFollowRedirects(true);
request.addRequestProperty("Content-Length", Integer.toString(query.length()));
request.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
request.addRequestProperty("Cookie", cook);
request.addRequestProperty("User-Agent", ua);
OutputStreamWriter writer = new OutputStreamWriter(request.getOutputStream());
writer.write(query);
writer.flush();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question