A
A
alexwprof2019-04-19 15:11:03
PHP
alexwprof, 2019-04-19 15:11:03

How to log in to a contact using curl without using api?

You need to log in to a contact without api using curl. Looked at a lot of information, all options no longer work. I send all the data, plus I substitute the ip_h and lg_h hashes. Sending the required headers. Everything flies to the address https://vk.com/login. As a result, it does not let.
I wonder if it is possible to log in via curl to VK in 2019 or not? Maybe it makes no sense and it's better to use the contact api? If you have a working version on curl, please share.
I am using code:

function get_content($url_auth, $auth_data = []){
    $ch = curl_init();
    curl_setopt  ($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch,CURLOPT_URL, $url_auth);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
    curl_setopt($ch, CURLOPT_REFERER,"https://vk.com");
    //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch,CURLOPT_COOKIEJAR, 'cs.txt');
    curl_setopt($ch,CURLOPT_COOKIEFILE, 'cs.txt');
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_ENCODING, "");
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt ($ch, CURLOPT_HTTPHEADER,
        [
            "Accept: */*",
            "Accept-Language: ru",
            "Cache-Control: max-age=259200",
            "Pragma: no-cache",
            "Via: 1.0 gsg-server.sitegroup:3129 (squid/2.6.STABLE5)",
            "X-Forwarded-For: 192.168.0.***",
            "Connection: Keep-Alive"
        ]

        );
    curl_setopt($ch,CURLOPT_POST, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($auth_data));
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

$url_auth = 'https://vk.com/login';
$url = 'https://vk.com/feed';
$auth_data = [
    "act" => "login",
    "role" => "al_frame",
    "expire" => "",
    "captcha_sid" => "",
    "captcha_key" => "",
    "_origin" => "https://vk.com",
    "ip_h" => "ef1366*****de28b0132",
    "lg_h" => "bb389*****bbcb9db4",
    "email" => "******@yandex.ru",
    "pass" => "*************",
    "recaptcha" => "",
    "ul" => "",
];

$data = get_content($url_auth, $auth_data);
$data = get_content($url);
var_dump($data);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dimmsan, 2019-04-21
@dimmsan

There is a working option, but there the entrance through m.vk.com allows you to do the same.
Library from the Simple HTML DOM
script The script is not mine, I don't remember the author, I also found it here on the Toaster.
Script

R
Rodion Gashé, 2019-04-19
@zorba_buddha

CURLOPT_REFERER exactly right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question