K
K
koxac2019-12-06 15:43:16
Java
koxac, 2019-12-06 15:43:16

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();

But it stopped working, I don’t understand what’s wrong, I tried to send everything through curl in bash that the browser sends, and we still get an authorization page

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
koxac, 2019-12-06
@koxac

Can't login with php either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question