ФорумПрограммированиеPHP для идиотов → Авторизация вк

Авторизация вк

  • Tracher

    Сообщения: 2 Репутация: N Группа: Кто попало

    Spritz 12 декабря 2010 г. 9:12

    Не могу раскурить почему не работает скрипт авторизации вк, кто подскажет?

      function Authorizate($login, $password)
    {

    $this->ch = curl_init('http://login.vk.com/?act=login');

    curl_setopt($this->ch, CURLOPT_COOKIEFILE, core::$x['VkGroupsForumsParser']['path_cookie']);

    curl_setopt($this->ch, CURLOPT_HEADER, true);
    curl_setopt($this->ch, CURLOPT_POST, true);
    curl_setopt($this->ch, CURLOPT_HTTPGET, false);
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);

    $data = array('email' => $login, 'pass' => $password, 'vk' => 1, );
    curl_setopt($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));

    $html = iconv('cp1251', 'utf-8', curl_exec($this->ch));

    if (!$data = $this->AuthorizateParseData($html))
    return false;

    curl_setopt($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($this->ch, CURLOPT_URL, 'http://vk.com/login.php');

    $html = iconv('cp1251', 'utf-8', curl_exec($this->ch));

    if ($this->AuthorizateIsSuccess($html))
    return;

    curl_setopt($this->ch, CURLOPT_URL, 'http://vk.com');

    curl_setopt($this->ch, CURLOPT_POST, false);
    curl_setopt($this->ch, CURLOPT_HTTPGET, true);

    $html = iconv('cp1251', 'utf-8', curl_exec($this->ch));

    curl_setopt($this->ch, CURLOPT_HEADER, false);
    curl_setopt($this->ch, CURLOPT_POSTFIELDS, '');

    return $this->AuthorizateIsSuccess($html);
    }

    private function AuthorizateIsSuccess($html)
    {
    return preg_match('{Location: /id[0-9]+}', $html);
    }
    private function AuthorizateParseData($html)
    {
    var_dump($html);
    $data = array('op' => 'slogin', 'redirect' => 1, 'expire' => 0, 'to' => '', );
    if (!preg_match("{<input type='hidden' name='s' id='s' value='(.*?)' />}", $html,
    $regs))
    return false;

    $data['s'] = $regs[1];

    return $data;
    }

  • phpdude

    Сообщения: 26646 Репутация: N Группа: в ухо

    Spritz 12 декабря 2010 г. 9:19, спустя 6 минут 44 секунды

    потому что не смазан
    Сапожник без сапог
  • Tracher

    Сообщения: 2 Репутация: N Группа: Кто попало

    Spritz 12 декабря 2010 г. 9:21, спустя 1 минуту 42 секунды

    потому что не смазан
    чем смазать то?вазелином чтоли..
  • Mars

    Сообщения: 304 Репутация: N Группа: Кто попало

    Spritz 12 декабря 2010 г. 16:03, спустя 6 часов 42 минуты 29 секунд

    проснифь авторизацию и напиши свой скрипт, делов то там…
  • Reestr

    Сообщения: 20 Репутация: N Группа: Кто попало

    Spritz 14 декабря 2010 г. 10:55, спустя 1 день 18 часов 51 минуту

    $email = '';
    $pass = '';


    $ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.4) Gecko/2008102920 AdCentriaIM/1.7 Firefox/3.0.4';
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, 'http://vkontakte.ru/login.php');
    curl_setopt ($ch, CURLOPT_HEADER, 0);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_USERAGENT, $ua);
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, 'act=login&success_url=&fail_url=&try_to_login=1&to=&vk=&email='.$email.'&pass='.$pass);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    $con = curl_exec($ch);
    curl_close ($ch);
    return $con;


    и пиздец

Пожалуйста, авторизуйтесь, чтобы написать комментарий!