Не могу раскурить почему не работает скрипт авторизации вк, кто подскажет?
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;
}