Всё, разобрался. Если что - вот код готовой авторизации на вконтакте в виде процедуры(мыло, пароль). Требует компоненты idhttp и idcookiemanager.
| Код | procedure getcookie(st:string); var i,j:integer; ncookie:string; begin ncookie:=''; for i:=1 to length(st) do if copy(st,i,10) = 'Set-Cookie' then begin for j := i+11 to length(st) do if st[j] = ';' then begin ncookie := ncookie + copy(st,i+11,j-i-10); break; end; end; if length(ncookie) > 50 then begin ncookie := 'Connection: Keep-Alive'+#13+'Cache-Control: no-cache'+#13+'Cookie: remixchk=5'+'Cookie: '+ncookie; frmcl.http.Request.CustomHeaders.Clear; frmcl.http.Request.CustomHeaders.Add(ncookie); end; end;
procedure login(mail,pass:string); var dt:tstringlist;s:string; begin frmcl.http.HandleRedirects:=true; frmcl.http.CookieManager:=frmcl.coom; frmcl.http.AllowCookies:=true; dt:=tstringlist.Create; dt.Add('op=a_login_attempt'); dt.add('email='+mail); dt.Add('pass='+pass); dt.add('expire=0'); s:=frmcl.http.Post('http://www.vkontakte.ru/login.php',dt); if (pos('good',s)<>0) then begin {messagebox(0,'Auth sucsess','Message',0);} LoggedIn:=true; end; if (s='failed') then begin {messagebox(0,'Login attempt falied','Message',0);} LoggedIn:=false; end; if (LoggedIn) then begin dt.Clear; dt:=frmcl.http.Response.RawHeaders; {got cookies. response ok.} getcookie(dt.Text); {set the fucking cookie to normal state. ok.} s:=frmcl.http.Get('http://www.vkontakte.ru/feed2.php'); if (s='{"user": {"id": -1}}') then LoggedIn:=false else LoggedIn:=true; end; if (not LoggedIn) then messagebox(0,'Вход не выполнен. Возможно, вы указали'+#13#10+'неверную пару логин/пароль.','Ошибка',0); if (LoggedIn) then messagebox(0,'U sucsessfuly logged in','Info',0); end;
|
Упд. Компоненты нужны (по крайней мере, точно будет работать всё) из indy10, свежие. Тидкукиманаджер и тидхттп - те,что были в пакетах, не измененные. |