Answer the question
In order to leave comments, you need to log in
How to log in to VK in Java without a browser?
Good day, gentlemen.
I use HttpClient 4.5.1, I try to log in to VK by sending a post-request to login.vk.com/?act=login with parameters:
email
pass
ip_h
lg_h
Looks like this:
HttpPost httpPostVk= new HttpPost("http://login.vk.com/?act=login");
List<NameValuePair> formparamsVk=new ArrayList<NameValuePair>();
formparamsVk.add(new BasicNameValuePair("email","******"));
formparamsVk.add(new BasicNameValuePair("pass","*******"));
formparamsVk.add(new BasicNameValuePair("ip_h",getIp_h()));
formparamsVk.add(new BasicNameValuePair("lg_h",getLg_h()));
UrlEncodedFormEntity entity2 = new UrlEncodedFormEntity(formparamsVk, Consts.UTF_8);
httpPostVk.setEntity(entity2);
HttpResponse response = httpclient.execute(httpPostVk);
Header[] headers= response.getAllHeaders();
for (int i=0;i<headers.length;i++) System.out.print(headers[i]+"\r\n");
Server: Apache
Date: Tue, 24 Nov 2015 14:13:59 GMT
Content-Type: text/html; charset=windows-1251
Connection: keep-alive
X-Powered-By: PHP/3.19062
Set-Cookie: remixlang=0; expires=Mon, 14 Nov 2016 17:40:33 GMT; path=/; domain=.vk.com
Pragma: no-cache
Cache-control: no-store
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Location: http://vk.com/login.php?&to=&s=0&m=1&email=
Answer the question
In order to leave comments, you need to log in
https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username=LOGIN&password=PASS
They don't do that.
To interact with VKontakte there is an API
https://vk.com/dev/main
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question