function VK_Login(email, pass: string): boolean; var Cookie : TidCookieManager; Data, Page : TStringList; I : Integer; S : string; begin HTTP := TIDHTTP.Create(NIL); Cookie := TidCookieManager.Create(nil); HTTP.AllowCookies := True; HTTP.HandleRedirects := True; HTTP.ProtocolVersion := pv1_1; HTTP.Request.UserAgent := 'Mozlilla/5.0'; HTTP.CookieManager := Cookie; Data := TStringList.Create; Page := TStringList.Create; HTTP.Post('http://vkontakte.ru/login.php', Data); Data.Add('act=login'); Data.Add('email=' + email); Data.Add('pass=' + pass); Page.Text := HTTP.Post('http://login.vk.com/', Data); For I := 0 To Page.Count -1 Do begin If Pos('id=' + #39 + 's' + #39, Page[i]) <> 0 Then begin S := Page[i]; S := Copy(s, Pos('value=', s) +7, Length(s)); Delete(s, Pos(#39, s), Length(s)); end; end; Data.Clear; Data.Add('op=slogin'); Data.Add('s=' + s); Page.Text := HTTP.Post('http://vkontakte.ru/login.php', Data); If Pos('error', Page.Text) <> 0 Then Result := False Else Result := True; Page.Free; Data.Free; end;
If ACookie.Domain[1] = '.' Then ACookie.Domain := Copy(ACookie.Domain, 2, Length(ACookie.Domain));