unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, IdIOHandler, IdIOHandlerSocket, IdSSLOpenSSL, httpsend, ssl_openssl,
OleCtrls, SHDocVw, synacode, synautil, Gauges, ExtCtrls, ComCtrls, Grids, DateUtils,
sSkinManager;
type
TForm1 = class(TForm)
btn1: TButton;
lbl1: TLabel;
edt2: TEdit;
mmo1: TMemo;
mmo2: TMemo;
lbl2: TLabel;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function FoundLocationStrNum(Headers: TStringlist): integer;
var
FoundStrPos, i: integer;
begin
Result := -1;
for i := 0 to Headers.Count do
begin
FoundStrPos := Pos('Location: ', Headers.Strings[i]);
if FoundStrPos > 0 then
begin
Result := i;
exit;
end;
end;
end;
function GetHTTPStr(http: THTTPSend): string;
var
BodyStream: TStringStream;
BodyS: TStringList;
begin
try
BodyS := TStringList.Create;
BodyStream := TStringStream.Create(result);
begin
BodyS.LoadFromStream(http.Document);
result := BodyS.Text;
end;
finally
BodyStream.Free;
BodyS.Free;
end;
http.Document.Seek(0, soFromBeginning);
end;
procedure TForm1.btn1Click(Sender: TObject);
label
ERRORLabel;
var
stream: TStringStream;
httpsend: THTTPSend;
Res: boolean;
n: integer;
KSlink, TOKEN, NewURL: string;
A0,A1,A2,A3:String;
REZ,z2,QW,result,before,after:String;
i,z1,w,t,l:Integer;
Cnt: Integer;
today : TDateTime;
lol1,GONJO:string;
lol2:Integer;
znach:Extended;
//
myDate,Date1,myDateX : TDateTime;
m1 : Integer;
begin
httpsend:=THTTPSend.Create;
httpsend.AddPortNumberToHost:= False;
httpsend.HTTPMethod('get', 'https://my.kyivstar.ua/tbmb/login/perform.do');
Application.ProcessMessages;
mmo1.Lines.LoadFromStream(httpsend.Document);
Application.ProcessMessages;
//-S-- Первый POST запрос ---
stream := TStringStream.Create('');
stream.WriteString('action=isCaptchaNeeded&user=%2B380980561942');
Application.ProcessMessages;
httpsend.Clear;
httpsend.MimeType := 'application/x-www-form-urlencoded';
httpsend.Document.LoadFromStream(stream);
Res := httpsend.HTTPMethod('post', 'https://my.kyivstar.ua/tbmb/checkUser');
Application.ProcessMessages;
//-E-- Первый POST запрос ---
//-S-- Второй POST запрос ---
stream := TStringStream.Create('');
stream.WriteString('isSubmitted=true&USERNAME=&USER_NAME=&ORIG_URL=&isInetUser=null&buser=&bpath=&user=%2B380980561942&password=435465&captcha=&value%28jumpTo%29=&value%28jumpToUrl%29=&Submit=%D3%E2%B3%E9%F2%E8');
Application.ProcessMessages;
httpsend.Clear;
httpsend.MimeType := 'application/x-www-form-urlencoded';
httpsend.Document.LoadFromStream(stream);
Res := httpsend.HTTPMethod('post', 'https://my.kyivstar.ua/tbmb/login/perform.do');
Application.ProcessMessages;
//-E-- Второй POST запрос ---
result:=IntToStr(httpsend.ResultCode);
if result = '302' then
begin
lbl2.Caption:='Good!';
Application.ProcessMessages;
end;
if result <> '302' then
begin
lbl2.Caption:='Bad!';
end;
if Res then
case httpsend.ResultCode of
301, 302, 307:
begin
n := FoundLocationStrNum(httpsend.Headers);
if (n >= 0) and (n <= httpsend.Headers.count) then
begin
NewURL := StringReplace(httpsend.Headers.Strings[n], 'Location: ', '', []);
Application.ProcessMessages;
httpsend.Clear;
httpsend.HTTPMethod('GET', NewURL);
Application.ProcessMessages;
mmo2.Lines.Text := GetHTTPStr(httpsend);
Application.ProcessMessages;
end;
end;
end;
end;
end.