Показать сообщение отдельно

  #8  
Старый 14.02.2010, 00:37
mailbrush
Познавший АНТИЧАТ
Регистрация: 24.06.2008
Сообщений: 1,996
Провел на форуме:
6075534

Репутация: 2731


По умолчанию

Моя функция авторизации:
PHP код:
function Request($url$postfields false$cookie false)
{
    
$ch curl_init($url);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION0);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_HEADER1);
    if (
$postfields)
    {
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$postfields);
    }
    if (
$cookie)
    {
        
curl_setopt($chCURLOPT_COOKIE$cookie);
    }
    
$res curl_exec($ch);
    return 
$res;
}

function 
LogIn($email$password)
{
    
Request('http://vkontakte.ru/login.php''op=a_login_attempt');
    
$vars Request('http://login.vk.com/?act=login''email=' $email '&pass=' $password .
        
'&expire=&vk=');
    
preg_match_all("#<input type='hidden' name='(.*)' id='.*' value='(.*)' />#"$vars$m);
    foreach (
$m[1] as $key => $value)
    {
        @
$postfields .= $value '=' $m[2][$key] . '&';
    }
    
$h Request('http://vkontakte.ru/login.php'$postfields);
    
preg_match('#remixsid=[a-z0-9]+#'$h$cookie);
    
$page Request('http://vkontakte.ru/'false$cookie[0]);
    
preg_match('#Location: /id(\d+)#'$page$id);
    return array(
'sid' => $cookie[0], 'id' => $id[1]);


 
Ответить с цитированием