
05.06.2010, 09:00
|
|
Постоянный
Регистрация: 26.07.2009
Сообщений: 321
С нами:
8838619
Репутация:
123
|
|
PHP код:
function vk_login($login,$pass)
{
$login = urlencode($login);
$pass = urlencode($pass);
$user_cookie_file = $_SERVER['DOCUMENT_ROOT'].'/cook.txt';
$ch = curl_init('http://login.vk.com/?act=login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.4');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_REFERER, 'http://vkontakte.ru/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $user_cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $user_cookie_file);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=$login&pass=$pass&expire=&vk=");
$res = curl_exec($ch);
file_put_contents('res.txt',$res);
if(!search_hash())die('Залогинится не получилось или не удается получить cookies.');
else
return true;
}
function search_hash(){
if(!preg_match ('#([a-z0-9]){36}#', file_get_contents('cook.txt'), $matches))return false;
else return true;}
PS: не рассказывай тем кто тебе помогает как "нужно было" - они шарят в этом намноооого больше 
|
|
|