08-01-2019, Saat: 00:33
idhttp ile ilgili makaleden yola çıkarak , bir siteye bağlanıp veri almayı başarabildim. Fakat orada anlamadığım bir konu var. Aşağıdaki şekilde giriş yaptıktan sonra farklı bir adrese yönleniyorum. Fakat 3 saniyede bir gelen bilgiyi yenilemek için IdHTTP.Get('http://deneme') şeklinde bilgi çekmek istediğimde program kırılıyor. Sebebini anlayamadım. Tekrar idhttp create edip denedim session düştü. Belli aralıklarla yenilemek için ne yapmalıyım hatam nerede ?
function baglan(const username, password: string): string; var IdHTTP: TIdHTTP; Request: TStringList; begin try Request := TStringList.Create; try Request.Add('work=login'); Request.Add('login_user='+username); Request.Add('login_pass='+password); IdHTTP := TIdHTTP.Create; try IdHTTP.AllowCookies := True; IdHTTP.HandleRedirects := True; IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded'; IdHTTP.Post('http://deneme/src/api.php', Request); Result := IdHTTP.Get('http://deneme'); if StrUtils.ContainsStr(Result, 'GİRİŞ YAP') then //Login başarısız Result := '' else begin Result := IdHTTP.Get('http://deneme/salon.html?id=1'); end; finally // IdHTTP.Free; end; finally Request.Free; end; except Result := ''; end; end;